C # / winforms: app shortcuts with exception on editable controls
in my C # / winforms application, I would like to do something like widescreen keys in the application bar that should launch anywhere except when the focus is on a control where the user can edit text, such as a textbox.
I am currently overwriting this function to do this.
protected override bool ProcessCmdKey(ref Message msg, Keys keyData);
How can I add an exception to this that it does not fire when the user is in an editable control?
thanks!
a source to share
I see 2 solutions here.
1) in each editable control, handle all keyboard events, and in the eventArgs object, set the Handled property to true:
e.Handled = true;
2) before doing the wide keyboard shortcut, find the control that has focus, and if it's a TextBox, ignore it. There is probably a method in every Form that indicates which control has focus.
The second option is cleaner. I don't give the code because I don't have Visual Studio right now, but if you need more specific code you can ask.
PS: here I did some searches for you: How to get FOcused Control?
a source to share