(27.09.2017 15:50)Valery Wrote: Nope, typing directly digits has no effect, need to hold control key in HD mod. Without HD is ok.
I tried on 4.208, few 5.0s and control key is not needed?
Anyhow, not really important.
@igrik
I tried my idea from previous post... it kind of works. It's not perfect but in the end only digits remain.

Я попробовал то, что написал в предыдущем посте... Это работает. Это не идеально, но в конце концов только цифры.
Code:
int __stdcall edit_text_proc(_Dlg_* dlg, _EventMsg_* msg)
{
int r = dlg->DefProc(msg);
if (msg->type == MT_KEYDOWN || msg->type == MT_KEYUP || msg->type == MT_MOUSEBUTTON) { // not absolutely necessary, less cpu intensive
_DlgTextEdit_ *edit = (_DlgTextEdit_*)(dlg->GetItem(55)); // id of _DlgTextEdit_
char edit_text[25]; // _DlgTextEdit_ max_len
sprintf(edit_text, edit->text); // copy _DlgTextEdit_ text
keep_digits(edit_text); // keep only '0123456789' in string (with !is_digit())
if (edit_text[0] == 0) { // strlen == 0
edit_text[0] = '0'; // put '0' as default
edit_text[1] = 0; // terminate string
}
sprintf(edit->text, edit_text); // replace _DlgTextEdit_ text
dlg->Redraw(); // redraw
}
return r;
}
EDIT:
Got it working nice and fine
Add this also when creating. Noticed it was happening with creature dialog.
Code:
_DlgTextEdit_* edit= (_DlgTextEdit_*)(dlg->GetItem(#EDIT_ID#));
edit->redraw_actions = FALSE;
In proc, have keep_digits(edit_text) return 1 / 0 depending whether a non-digit was found e.g.
Code:
int keep_digits(char* input)
{
char* dest = input;
char* src = input;
int non_digit = 0;
while (*src)
{
if (!isdigit(*src)) {
non_digit = 1;
src++;
continue;
}
*dest++ = *src++;
}
*dest = '\0';
return non_digit;
}
If true, decrease position of cursor "caret".
Code:
if (keep_digits(edit_text))
edit->caret_pos--;
Only "slight" bug is CTRL-V "paste"... cursor "caret" vanishes with non-digits.
...don't care too much about that one.