The documentation states:
We've found that this is only partly true and is different for Linux and Windows. The following code can be used to show the problems.#PB_Canvas_Key Returns the key that was pressed or released in a #PB_EventType_KeyDown or #PB_EventType_KeyUp event. The returned value is one of the #PB_Shortcut_... values used by the AddKeyboardShortcut() function. This attribute returns raw key presses.
Code: Select all
OpenWindow(0,0,0,200,200,"Canvas Gadget",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
CanvasGadget(1, 50, 50, 100, 30, #PB_Canvas_Border | #PB_Canvas_Keyboard | #PB_Canvas_DrawFocus)
SetActiveGadget(1)
Repeat
iWindowEvent = WaitWindowEvent()
Select iWindowEvent
Case #PB_Event_Gadget
Select EventType()
Case #PB_EventType_KeyUp
Debug GetGadgetAttribute(1, #PB_Canvas_Key)
; Case #PB_EventType_KeyDown
; Debug GetGadgetAttribute(1, #PB_Canvas_Key)
; Case #PB_EventType_Input
; Debug Chr(GetGadgetAttribute(1, #PB_Canvas_Input))
EndSelect
EndSelect
Until iWindowEvent = #PB_Event_CloseWindow
Linux (KeyUp): Caps lock on (or the Shift key pressed), Num lock must be on
Linux (KeyDown): Num lock must be on
Windows (KeyUp): Num lock must be on
Windows (KeyDown): Num lock must be on
Rather than generating raw key codes, PB is generating case sensitive codes for letters and keypad keys. Also, the keys for special characters such as comma, semicolon, etc, and the keypad Enter, have no defined "#PB_Shortcut_...." values.
I'd like to know if this is a bug or is the intended behaviour.
Every key should have only one possible code, and the code should be defined in the list of "#PB_Shortcut_...." values, or perhaps in its own set of "#PB_Rawkey_...." values to avoid creating problems for the shortcut feature.
Thanks