Page 1 of 1

Default Button

Posted: Mon Jul 26, 2010 4:50 pm
by tbohon
I have a simple form with a couple of data entry fields and a 'Submit' button. I've successfully gotten the 'Submit' button to show as the default but after entering the data into the fields I press the 'Enter' key and the button's events aren't executed.

Is there something else I need to do? I was thinking maybe it had to do with the tab order but changing that didn't help either.

I'll promise to be appropriately embarassed with the answer if you promise not to laugh (too loudly anyway) ... :D

Thanks in advance.

Tom

Re: Default Button

Posted: Mon Jul 26, 2010 5:14 pm
by srod
Use a keyboard shortcut for the return key.

The default button style is just that, a visual style (at least it is without taking additional steps in the message retrieval loop). If you used a modal dialog (Windows only) then the default button would indeed behave in the way you expect. For windows (as opposed to dialogs), however, you generally have to trap the return key yourself. Do a search for IsDialogMessage_() for further discussions of this type of thing.

Re: Default Button

Posted: Mon Jul 26, 2010 5:14 pm
by ts-soft
The standard for a window is the space key!
Only on Dialogwindows you use the enterkey. You have to integrate this by yourself
(see AddKeyboardshortcut)

greetings

Thomas

// srod is faster :wink:

Re: Default Button

Posted: Mon Jul 26, 2010 5:18 pm
by srod
ts-soft wrote:// srod is faster :wink:
Aye, you have to get up pretty damn early in the afternoon to catch srod out! :)

Re: Default Button

Posted: Tue Jul 27, 2010 3:02 am
by tbohon
Thanks for the explanation gentlemen - much appreciated.

Tom