Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Dude
Addict
Posts: 1907 Joined: Mon Feb 16, 2015 2:49 pm
Post
by Dude » Sat Sep 22, 2018 6:18 am
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!
RSBasic
Moderator
Posts: 1228 Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:
Post
by RSBasic » Mon Sep 24, 2018 8:38 am
+1
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
Dude
Addict
Posts: 1907 Joined: Mon Feb 16, 2015 2:49 pm
Post
by Dude » Mon Sep 24, 2018 8:43 am
RSBasic, thanks... but it doesn't return Shift+Ctrl+Alt+T correctly. It shows Shift+Strg+A (it's missing Alt).
forumuser
User
Posts: 98 Joined: Wed Apr 18, 2018 8:24 am
Post
by forumuser » Mon Sep 24, 2018 9:40 am
set it to 16 and try again
@RSBasic
Cmd = Win key?
Should that key actually work (it has it's normal function, e.g. it calls the start menu when pressed)?
Dude
Addict
Posts: 1907 Joined: Mon Feb 16, 2015 2:49 pm
Post
by Dude » Mon Sep 24, 2018 12:59 pm
forumuser wrote:
set it to 16 and try again?
Yep, that works. Thanks!
Rinzwind
Enthusiast
Posts: 679 Joined: Wed Mar 11, 2009 4:06 pm
Location: NL
Post
by Rinzwind » Mon Nov 18, 2019 7:23 am
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?