I'm making form level shortcuts with form application.
First, it works with strip menus, however their shortcuts must be combination of any modifier and a word or decimal key. I need only a word or decimal key shortcut. Therefore it does not fit my needs.
And I tried a method that KeyDown
and KeyUp
events with form's KeyPreview
set to true
. If I handled the word or decimal keys with Handled
and SuppressKeyPress
set to true
in those events, the child control cannot receive the input even though the control is TextBox
or NumericUpDown
that is a control that allows text input. Overriding ProcessCmdKey
has the same issue.
And then, I tried to check the focusing control actually needs the input by calling focusing control's IsInputKey
and IsInputChar
. Yes, you cannot call them normally because these methods are protected
. I used reflection. But I had no luck. These were not working as I expected.
Finally, I applied a branch that checks the focusing control is TextBox
or something allowing input. I had no luck with this either. Because the NumericUpDown
's real focus control is a private class called UpDownBase.UpDownEdit
. It means that some other controls can have similar mechanism that cannot expect in build time. In short, it can cause bugs.
I think, I could solve this issue if there was a way to catch unhandled input in last key handling phase such like bubbling. But I couldn't find information about it for form applications.
Do I have to override ALL of child controls' ProcessCmdKey
s?
Really isn't there a fancy way to solve this problem?