SetGadgetState() for ShortcutGadget() is wrong

Windows specific forum
infratec
Always Here
Always Here
Posts: 6817
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

SetGadgetState() for ShortcutGadget() is wrong

Post by infratec »

SetGadgetState() for ShortcutGadget() gives wrong results.

Code: Select all

OpenWindow(0, 0, 0, 210, 30, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)

ShortcutGadget(0, 5, 5, 200, 20, 0)
SetGadgetState(0, #PB_Shortcut_Up)

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
Tested with PB 5.71 x86 on Win10 x64
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

Re: SetGadgetState() for ShortcutGadget() is wrong

Post by kenmo »

For what it's worth, this is just a display problem.

If you read back the integer value with GetGadgetState() it is correct!

Code: Select all

OpenWindow(0, 0, 0, 210, 30, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
ShortcutGadget(0, 5, 5, 200, 20, 0)

s = #PB_Shortcut_Pad8
SetGadgetState(0, s)
Debug "Should be " + Str(s) + ": " + Str(GetGadgetState(0))

s = #VK_UP ; Windows constant equal to PB constant
SetGadgetState(0, s)
Debug "Should be " + Str(s) + ": " + Str(GetGadgetState(0))

s = #PB_Shortcut_Up
SetGadgetState(0, s)
Debug "Should be " + Str(s) + ": " + Str(GetGadgetState(0))

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

Re: SetGadgetState() for ShortcutGadget() is wrong

Post by kenmo »

netmaestro posted a "ShortcutGadgetEx" which fixes some other things, but it still has this problem :shock:

viewtopic.php?f=12&t=40523
Fred
Administrator
Administrator
Posts: 16619
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: SetGadgetState() for ShortcutGadget() is wrong

Post by Fred »

We just send the hotkey via HKM_SETHOTKEY without interfering so it's probably a Windows oddity. It could be explained because Pad8 is actually UP if the Verrnum is not set.
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

Re: SetGadgetState() for ShortcutGadget() is wrong

Post by kenmo »

It seems you're right. I haven't used HOTKEY_CLASS before, but it appears to have the same issue (shows Up as "Num 8" but if I press the up key, it does say "Up").

I asked because I'm going to submit new hotkeys to the IDE project, but the arrow keys display wrong when opening the shortcut prefs! (Windows' fault.)

Code: Select all

If OpenWindow(0, 0, 0, 240, 170, "ShortcutGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ShortcutGadget(0, 20, 20, 200, 25, #PB_Shortcut_Up)
  
  *hwndHot = CreateWindowEx_(0, #HOTKEY_CLASS, #Null, #WS_CHILD | #WS_VISIBLE, 20, 60, 200, 20, WindowID(0), #Null, GetModuleHandle_(#Null), #Null)
  SendMessage_(*hwndHot, #HKM_SETHOTKEY, #VK_UP, 0)
  
  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
  
  CloseWindow_(*hwndHot)
EndIf

EDIT: Similarly, it displays the regular Delete shortcut as "Num Del"

Code: Select all

If OpenWindow(0, 0, 0, 240, 170, "ShortcutGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ShortcutGadget(0, 20, 20, 200, 25, #PB_Shortcut_Delete)
 
  *hwndHot = CreateWindowEx_(0, #HOTKEY_CLASS, #Null, #WS_CHILD | #WS_VISIBLE, 20, 60, 200, 20, WindowID(0), #Null, GetModuleHandle_(#Null), #Null)
  SendMessage_(*hwndHot, #HKM_SETHOTKEY, #VK_DELETE, 0)
 
  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
 
  CloseWindow_(*hwndHot)
EndIf
Post Reply