Gadget for capturing raw keyboard input?

Just starting out? Need help? Post your questions and find answers here.
Quin
Addict
Addict
Posts: 1135
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Gadget for capturing raw keyboard input?

Post 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.
User avatar
kenmo
Addict
Addict
Posts: 2051
Joined: Tue Dec 23, 2003 3:54 am

Re: Gadget for capturing raw keyboard input?

Post 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...
Post Reply