[Implemented] KeyboardShortcut

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

[Implemented] KeyboardShortcut

Post by BackupUser »

Restored from previous forum. Originally posted by horst.

The KeyboardShortcut works nicely, but is there any way
to find out which gadget currently has the focus???

EventGadgetID() gives me the same value as EventMenuID()

Horst.

(Implemented as 'GetActiveGadget()')
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.

Use the API call:

ActiveHWND = GetFocus_()

The GetFocus function retrieves the handle of the GUI object.



Have a nice day...
Franco

Sometimes you have to go a lonely way to accomplish genius things.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by horst.
ActiveHWND = GetFocus_()
Yeah, thanks Franco.
Now I can check whether the focus is on the OK button
(and not on "cancel") when ENTER is pressed:

if GetFocus_() = GadgetID(#OkButton) ....

Horst.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

You can use the 'PB_Button_Default' flag for the default button. On Windows, even if the focus is on the Cancel button, pressing Enter will be like pressing OK.

Fred - AlphaSND
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by horst.

I have tested it. Does this have any effect other than
informing the user about the default button?

I have a TreeGadget, a StringGadget and two ButtonGadgets,
for example, and when the Enter key is pressed, I have to
take different action depending on the gadget that has the
focus.

That means I have to check each gadget whether it has the
focus, and then do the appropriate action.

It would be much esier, if Enter would just supply the
EventGadgetID(), and EventType() could tell me that it was
the Enter key.

How about that?

Horst.
Post Reply