Window Keydown event bug - randomly looses focus

Hi
I made an app that asks the user to write small words, not on a textfield but directly on a label using the window keydown event.
It works fine most of the times but randomly sometimes it doesnt recocnize any keypresses
is there any way I can workaround this bug and make the app “refocus” thanks

regards

You might check which control has received the focus, and perhaps disable the tabstop for them, or pass through the keypress events from all controls so that it is the window which handles them?

As Jeff has surmised, I would think your label is losing the focus. Just out of curiosity, why are you using the Window’s Keydown event rather than just using the Label’s own Keydown event?

I don’t see where there is a bug.

Sorry, it’s not a label it’s a bevel control. Anyways. It’s definitely a bug since it happens with no reason and totally randomly.
A similar bug (already reported ) happens when the mouse it’s over the bevel control it raises a windows exit event.

I’m am “lucky” that it happens rarely

[quote=181154:@Horacio Vilches]Sorry, it’s not a label it’s a bevel control. Anyways. It’s definitely a bug since it happens with no reason and totally randomly.
A similar bug (already reported ) happens when the mouse it’s over the bevel control it raises a windows exit event.

I’m am “lucky” that it happens rarely[/quote]

The bug in question is just a Mouse Exit, not a Windows Exit. But it is still here in 2015R2.

Your focus issue can probably be fixed by making sure the Bevel Button keeps the focus. You may want to use a window boolean property called for instance “keepFocus” that tells the program to keep the focus on the BevelButton.

You could set it True when the user clicks the button, for instance.

Then you place that in the BevelButton’s LostFocus event :

If keepFocus then me.SetFocus

Make sure in all other controls such as buttons, TextFields and such to False the keepFocus property to free the focus. It does fine in these controls GotFocus event :

keepFocus = False