Re: Comma and decimal point as a decimal separator
Posted: Sat Nov 05, 2011 10:56 am
Watching my users occasionally struggle with the rather strict NUMERIC textboxes in hmg, I noticed several difficulties:
It is not only the comma / point confusion. With the cursor on the very right, users want to delete all characters by pressing backspace, but can't get past the decimal point because it is protected. Iif the cursor is on the left and you use the delete key only one character gets deleted and neither the following numbers, nor the caret moves. So if you press a second time, nothing happens.
This behavior is different from console-mode, where you can delete all numbers by pressing del or backspace several times. Neither is it consistent with other windows-programs like excel.
To give my users a bit of freedom, I declared textboxes as CHARACTER and bound them to database-fields by means of onChange and onLostfocus events. My users are happy, but my code does not look nice.
Because I was unhappy with my ugly hack, I altered hmg-sourcecode h_windows and removed the line 1467
Now the InputMask is ignored during typing, but only used to format the input to a valid number when the control loses focus. Hmg does a pretty good job transforming it to a valid number. Only one alternation is necessary if you use FORMAT "E" (decimal-comma). If a user does not type "," or ".", the INPUTMASK is ignored. That is because in line 1511ff there, an otherwise-clause is missing.
So I replaced
with this
I suggest a new option to enable this behavior. Maybe FORMATMASK as opposed to INPUTMASK. So programers can decide if the mask should be checked during or after input.
What do you think?
It is not only the comma / point confusion. With the cursor on the very right, users want to delete all characters by pressing backspace, but can't get past the decimal point because it is protected. Iif the cursor is on the left and you use the delete key only one character gets deleted and neither the following numbers, nor the caret moves. So if you press a second time, nothing happens.
This behavior is different from console-mode, where you can delete all numbers by pressing del or backspace several times. Neither is it consistent with other windows-programs like excel.
To give my users a bit of freedom, I declared textboxes as CHARACTER and bound them to database-fields by means of onChange and onLostfocus events. My users are happy, but my code does not look nice.
Because I was unhappy with my ugly hack, I altered hmg-sourcecode h_windows and removed the line 1467
Code: Select all
ProcessCharmask ( i , .t. )
So I replaced
Code: Select all
Do Case
Case At ( '.' , Ts ) > At ( ',' , Ts )
SetWindowText ( _HMG_SYSDATA [3] [i] , Transform ( GetNumFromText ( GetWindowText ( _HMG_SYSDATA [3][i] ) , i ) , _HMG_SYSDATA [ 7 ][i] ) )
Case At ( ',' , Ts ) > At ( '.' , Ts )
SetWindowText ( _HMG_SYSDATA [3] [i] , Transform ( GetNumFromTextSp ( GetWindowText ( _HMG_SYSDATA [3][i] ) , i ) , _HMG_SYSDATA [ 7 ][i] ) )
EndCase
Code: Select all
IF At ( ',' , Ts ) > At ( '.' , Ts )
SetWindowText ( _HMG_SYSDATA [3] [i] , Transform ( GetNumFromTextSp ( GetWindowText ( _HMG_SYSDATA [3][i] ) , i ) , _HMG_SYSDATA [ 7 ][i] ) )
else
SetWindowText ( _HMG_SYSDATA [3] [i] , Transform ( GetNumFromText ( GetWindowText ( _HMG_SYSDATA [3][i] ) , i ) , _HMG_SYSDATA [ 7 ][i] ) )
endif
What do you think?