No keydown event for tab on a canvas

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
❤x1
User
User
Posts: 49
Joined: Thu Jan 10, 2019 5:56 pm

No keydown event for tab on a canvas

Post by ❤x1 »

Hello,

On Windows 11 with PB 6.03b9, there is no KeyDown event for tab key on a canvas gadget, but there is one for KeyUp.

Code: Select all

Procedure CanvasCallback_KeyUp()
	Debug "KeyUp: " +  GetGadgetAttribute(0, #PB_Canvas_Key)
EndProcedure

Procedure CanvasCallback_KeyDown()
	Debug "KeyDown: " + GetGadgetAttribute(0, #PB_Canvas_Key)
EndProcedure

OpenWindow(0, 0, 0, 200, 200, "Canvas key event", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

CanvasGadget(0, 10, 10, 180, 180, #PB_Canvas_Keyboard)
BindGadgetEvent(0, @CanvasCallback_KeyDown(), #PB_EventType_KeyDown)
BindGadgetEvent(0, @CanvasCallback_KeyUp(), #PB_EventType_KeyUp)
SetActiveGadget(0)

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
User avatar
STARGÅTE
Addict
Addict
Posts: 2227
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: No keydown event for tab on a canvas

Post by STARGÅTE »

To my understanding, there can't be a KeyDown event for the TAB key, because in the moment you press the TAB down, you switch the gadget and the CanvasGadget loses the focus. On the other hand you receive a KeyUp event, because you have only one gadget and the CanvasGadget is focused again.
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
❤x1
User
User
Posts: 49
Joined: Thu Jan 10, 2019 5:56 pm

Re: No keydown event for tab on a canvas

Post by ❤x1 »

Oh. Ok then, it's probably not a bug.
Mr.L
Enthusiast
Enthusiast
Posts: 146
Joined: Sun Oct 09, 2011 7:39 am

Re: No keydown event for tab on a canvas

Post by Mr.L »

To me it is a bug...
It has worked in the previous purebasic version, if you removed the Keyboardshortcut for the tab key after the window has been opened (which makes sense to me).
What has changed in the latest update?

If it's not a bug, there should definitely be an option to detect this key
Post Reply