Editbox Validation when hitting enter
-
Hi! How do I make an edit box only validate it's contents when hitting the enter key? The edit box is attached to a variable, and I only want the variable to get updated when I hit enter. Something that's not necessary, but a "nice to have" would be doing the same thing for the tab key. Besides doing the validation, it would also tab over to the next control. Steve
-
Hi! How do I make an edit box only validate it's contents when hitting the enter key? The edit box is attached to a variable, and I only want the variable to get updated when I hit enter. Something that's not necessary, but a "nice to have" would be doing the same thing for the tab key. Besides doing the validation, it would also tab over to the next control. Steve
You need to use the OnKeyDown. When you detect the Enter, you can validate the Edit. Cheers!!! Carlos Antollini.
-
Hi! How do I make an edit box only validate it's contents when hitting the enter key? The edit box is attached to a variable, and I only want the variable to get updated when I hit enter. Something that's not necessary, but a "nice to have" would be doing the same thing for the tab key. Besides doing the validation, it would also tab over to the next control. Steve
The usual way of doing this is to handle validation in the OnKillFocus method call for that object. Then, hitting Enter (which will submit the dialog if the edit control is on a dialog) or hitting Tab (which will go to the next field in the tab order if if the edit control is on a dialog) will both kick-off that event. If you're rolling your own interface in a non-dialog setting, you should be subclassing the parent window to pre process all the messages that come through your main window proc, and that would be where you would do Enter and Tab key handling (and other key for that matter).