Troubleshooting Key Press Event in Form

The form may not respond to the key press event, the only reason is that the form has lost the keyboard focus. But the form is designed to ignore the keyboard focus by clicking on it, it means that the form will never get the focus by clicking on it. To have the form get focused, we can
1, set focus explicitly by calling

nana::API::focus_window(form); //or
form.focus();

 

2, don’t let the form ignore the keyboard focus by clicking on it.

nana::API::ignore_mouse_focus(form, false);

 

Leave a Reply