The ShortcutGadget() was added in 2009 and I only literally just discovered it now!
However, I see that GetGadgetState() only returns the keycode value for it, so it'd be extra handy if GetGadgetText() returned the actual text in it. After all, any gadget that holds text should have a way of having said text returned. In this case, it would mean we could easily get (for example) "Ctrl +A" without having to code a routine to convert 131137 to "Ctrl + A".
Thanks!
GetGadgetText for ShortcutGadget
- RSBasic
- Moderator
- Posts: 1218
- Joined: Thu Dec 31, 2009 11:05 pm
- Location: Gernsbach (Germany)
- Contact:
Re: GetGadgetText for ShortcutGadget
+1
Until the function was developed, here is a temporary solution:
Until the function was developed, here is a temporary solution:
Code: Select all
EnableExplicit
;By Wolfram
Procedure.s shortcutToString(SC)
Protected string.s{12}, modifiyer
modifiyer = SC >>16
If modifiyer & 1
string ="Shift+"
EndIf
modifiyer >>1
If modifiyer & 1
string +"Strg+"
EndIf
modifiyer >>1
If modifiyer & 1
string +"Alt+"
EndIf
modifiyer >>1
If modifiyer & 1
string +"Cmd+"
EndIf
string +UCase(Chr(SC & $FFFF))
ProcedureReturn string
EndProcedure
If OpenWindow(0, 0, 0, 500, 400, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ShortcutGadget(1, 10, 10, 200, 20, 0)
Repeat
Select WaitWindowEvent()
Case #PB_Event_Gadget
Select EventGadget()
Case 1
Debug shortcutToString(GetGadgetState(1))
EndSelect
Case #PB_Event_CloseWindow
End
EndSelect
ForEver
EndIf
Re: GetGadgetText for ShortcutGadget
RSBasic, thanks... but it doesn't return Shift+Ctrl+Alt+T correctly. It shows Shift+Strg+A (it's missing Alt).
Re: GetGadgetText for ShortcutGadget
Code: Select all
string.s{12}
@RSBasic
Cmd = Win key?
Should that key actually work (it has it's normal function, e.g. it calls the start menu when pressed)?
Re: GetGadgetText for ShortcutGadget
Yep, that works. Thanks!forumuser wrote:set it to 16 and try again?Code: Select all
string.s{12}
Re: GetGadgetText for ShortcutGadget
GetGadgetText works now right?
Anyway, do you also have a stringToShortcut function laying around?
SetGadgetText(sc, "⌃C")
Debug GetGadgetState(sc)
doesn't work..
Also seems like ShortcutGadget does not send a #PB_Event_Gadget event?
Anyway, do you also have a stringToShortcut function laying around?
SetGadgetText(sc, "⌃C")
Debug GetGadgetState(sc)
doesn't work..
Also seems like ShortcutGadget does not send a #PB_Event_Gadget event?