I see what the ShortCutGadget() does, but how is it useful?
Would it normally be used as an invisible gadget?
Can someone please provide a working example of using this gadget.
Help Needed for ShortCutGadget()
Help Needed for ShortCutGadget()
Anthony Jordan
Just see there : http://www.purebasic.fr/english/viewtop ... 697#295697
@Progi1984:
Thanks for your help, but I had already spotted that post, however I still don't see how the ShortcutGadget is intended to be used in practice.
In what sort of applications would this be a valuable gadget to have?
Is it's only use to convert a keypress to an Ascii representation or has it got other useful properties?
Thanks for your help, but I had already spotted that post, however I still don't see how the ShortcutGadget is intended to be used in practice.
In what sort of applications would this be a valuable gadget to have?
Is it's only use to convert a keypress to an Ascii representation or has it got other useful properties?
Anthony Jordan
> I still don't see how the ShortcutGadget is intended to be used in practice.
It is intended to let the user choose a keyboard shortcut for something. Just like the IDE in its Preferences does. Get/SetGadgetState() can be used on the gadget to get/set the current shortcut. The values are passed using the #PB_Shortcut_XXX constants, so you could directly use the GetGadgetState() value from the ShortcutGadget() in a call to AddKeyboardShortcut() to add this shortcut to your window.
It is intended to let the user choose a keyboard shortcut for something. Just like the IDE in its Preferences does. Get/SetGadgetState() can be used on the gadget to get/set the current shortcut. The values are passed using the #PB_Shortcut_XXX constants, so you could directly use the GetGadgetState() value from the ShortcutGadget() in a call to AddKeyboardShortcut() to add this shortcut to your window.
quidquid Latine dictum sit altum videtur
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
You can also use it as a hotkey gadget for your window:
Minimize the window and hit the hotkey combo to test.
@freak: Could the SendMessages be wrapped to a PB command, e.g. SetWindowHotkey() or such? (on windows, anyway. dunno from other OS's)
Code: Select all
OpenWindow(0,0,0,320,240,"",#PB_Window_ScreenCentered|#PB_Window_SystemMenu|#PB_Window_MinimizeGadget)
ShortcutGadget(0,10,10,100,20, #PB_Shortcut_Alt|#PB_Shortcut_A)
sc.w = SendMessage_(GadgetID(0),#HKM_GETHOTKEY,0,0)
SendMessage_(WindowID(0), #WM_SETHOTKEY, sc, 0)
Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow
@freak: Could the SendMessages be wrapped to a PB command, e.g. SetWindowHotkey() or such? (on windows, anyway. dunno from other OS's)
BERESHEIT
@ freak & netmaestro:
Thank you for your posts which has made everything so much clearer.
I see the gadget is based on the Windows Hot Key Control which until now I never knew existed.
I agree with Horst that Get/SetGadgetText() would be useful finishing touches.
I expect that SetGadgetText() would only change the gadget's text area contents without affecting the state of the ShortcutGadget().
Which PB events are raised by the gadget?
Thank you for your posts which has made everything so much clearer.
I see the gadget is based on the Windows Hot Key Control which until now I never knew existed.
I agree with Horst that Get/SetGadgetText() would be useful finishing touches.
I expect that SetGadgetText() would only change the gadget's text area contents without affecting the state of the ShortcutGadget().
Which PB events are raised by the gadget?
Anthony Jordan
Because it wouldn't be crossplatform. OSX uses symbols to represent the keys instead of names, and these symbols are unicode characters. So an ascii program wouldn't be able to represent them in a string.horst wrote:Why can't we have GetGadgetText() in case we would like to inform the user about the current shortcut (in a menu, tooltip or any text info)?freak wrote:Get/SetGadgetState() can be used on the gadget to get/set the current shortcut.
Also MenuItem() requires english Key names for the shortcut on Linux and OSX (because they have to be parsed back into OS constants actually) so if this gadget returns a language-specific text, you wouldn't be able to use it there anyway.
quidquid Latine dictum sit altum videtur
Re:
How does PB itself then write shortcut-key-text like in the Preferences Shortcut Tab ?freak wrote:Because it wouldn't be crossplatform. OSX uses symbols to represent the keys instead of names, and these symbols are unicode characters. So an ascii program wouldn't be able to represent them in a string.horst wrote:Why can't we have GetGadgetText() in case we would like to inform the user about the current shortcut (in a menu, tooltip or any text info)?
Also MenuItem() requires english Key names for the shortcut on Linux and OSX (because they have to be parsed back into OS constants actually) so if this gadget returns a language-specific text, you wouldn't be able to use it there anyway.
I would like to get that but it probably needs the API way then, or not (here on XP) ?
Thanks.
Yeah I know, but keep in mind ... Leonardo da Vinci was also an autodidact.