Page 1 of 1

Gadget for capturing raw keyboard input?

Posted: Sat Oct 05, 2024 1:35 am
by Quin
I'm looking for some sort of gadget that can take the keyboard focus, and when it does, lets you process the keys any way you'd like. My first thought on the best way to do this is to subclass a TextGadget() and make it able to take keyboard focus, and also overwrite its handling of WM_KEYDOWN and so on. I have a small amount of experience subclassing edit controls in PB, but have utterly no idea how to do this. It's also possible that I'm way overcomplicating it or there's an existing solution. Any guidance or tips here?
Thanks,
Quin.

Re: Gadget for capturing raw keyboard input?

Posted: Sat Oct 05, 2024 3:02 am
by kenmo
The CanvasGadget may be exactly what you need, see #PB_Canvas_Keyboard and perhaps #PB_Canvas_DrawFocus, get the key events with #PB_EventType_KeyDown and #PB_EventType_Input, and read GetGadgetAttribute() with #PB_Canvas_Key and #PB_Canvas_Input...