Default Button

Just starting out? Need help? Post your questions and find answers here.
tbohon
User
User
Posts: 42
Joined: Sat Nov 22, 2008 4:22 am
Location: Olympia, WA USA

Default Button

Post 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
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: Default Button

Post 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.
I may look like a mule, but I'm not a complete ass.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Default Button

Post 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:
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: Default Button

Post 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! :)
I may look like a mule, but I'm not a complete ass.
tbohon
User
User
Posts: 42
Joined: Sat Nov 22, 2008 4:22 am
Location: Olympia, WA USA

Re: Default Button

Post by tbohon »

Thanks for the explanation gentlemen - much appreciated.

Tom
Post Reply