I am relateively new to programming for Windows so please bare with me.
I have a window that I am trying to use the keydown event in. In my event I only have msgbox key right now (to show what key is being pressed). It never fires. so I put the same code in keyup to make sure keydown wasnt firing but keyup was. still nada.
my forums search-fu suggested that a listbox might be eating the keys. On that window I have no listboxes. checkboxes, textareas, textfields, labels, and bevel buttons. Now on the main window that launches this secondary window has a listbox. but I “hide” that window when I launch this window.
Focus +1. It is very possible for the window itself to lose focus. Windows Desktop tends to grab focus so you can navigate the icons with the keyboard.
I created a new project with no control on the window. Added KeyDown with MsgBox Key into it. Fires very nicely.
However, when I add a TextField, it steals the event.
You may want to put a System.debuglog in the GotFocus event of each of your controls. Maybe one of them you do not think gets focus is doing it. A ClearFocus could largely improve the situation as well.
Finally, in order to alleviate this keydown nitty-gritty, if what you need is to monitor the keys, sometimes a timer that checks Keyboard.AsyncKeyDown can do wonder. Or a menuitem shortcut.
@Tim Hare and @Michel Bujardet thanks for the ideas. I will try them.
on a side note, I rather program for Mac. I tend not to have these odd issues. And I dont think my issues with Windows is a Xojo thing but a Windows thing. I blame Redmond and I am only slightly sarcastic about that statement.
For me after calling ClearFocus on Windows I needed to call SetFocus on window to have key events work.
Maybe you call SetFocus in Windows in some places?