S
Sune Foldager
Greetings,
There is a bug in the method System.Windows.Forms.ToolStrip.ProcessCmdKey
which can cause application-wide shortcuts to stop working. For instance,
we have an application where there is a global shortcut ctrl + k to open
a form. Whenever the toolstrip is active, however, pressing ctrl + k will
instead behave as if you pressed ctrl + tab.
The problem is the following line from System.Windows.Forms.ToolStrip.ProcessCmdKey
(here reconstructed using the .NET Reflector):
if ((!this.IsDropDown && ((keyData & (Keys.Control | Keys.Tab)) == (Keys.Control
| Keys.Tab))) && (!this.TabStop && this.HasKeyboardInput))
In particular, the following part which is supposed to determine if ctrl
+ tab was pressed:
(keyData & (Keys.Control | Keys.Tab)) == (Keys.Control | Keys.Tab))
But this is clearly a bug, since every keycode for which kc & Keys.Tab ==
Keys.Tab (i.e. 8) will satisfy the condition, including k as well as several
other alphabetic characters. The entire line should instead be:
if ((!this.IsDropDown && ((keyData & Keys.Control) == Keys.Control) &&
((keyData & Keys.KeyCode) == Keys.Tab) && (!this.TabStop && this.HasKeyboardInput))
Which would fix the bug. Right now we had to hack around it instead. The
bug has existed at least since .NET 1.1.
Sincerly,
Sune Foldager
Edlund A/
There is a bug in the method System.Windows.Forms.ToolStrip.ProcessCmdKey
which can cause application-wide shortcuts to stop working. For instance,
we have an application where there is a global shortcut ctrl + k to open
a form. Whenever the toolstrip is active, however, pressing ctrl + k will
instead behave as if you pressed ctrl + tab.
The problem is the following line from System.Windows.Forms.ToolStrip.ProcessCmdKey
(here reconstructed using the .NET Reflector):
if ((!this.IsDropDown && ((keyData & (Keys.Control | Keys.Tab)) == (Keys.Control
| Keys.Tab))) && (!this.TabStop && this.HasKeyboardInput))
In particular, the following part which is supposed to determine if ctrl
+ tab was pressed:
(keyData & (Keys.Control | Keys.Tab)) == (Keys.Control | Keys.Tab))
But this is clearly a bug, since every keycode for which kc & Keys.Tab ==
Keys.Tab (i.e. 8) will satisfy the condition, including k as well as several
other alphabetic characters. The entire line should instead be:
if ((!this.IsDropDown && ((keyData & Keys.Control) == Keys.Control) &&
((keyData & Keys.KeyCode) == Keys.Tab) && (!this.TabStop && this.HasKeyboardInput))
Which would fix the bug. Right now we had to hack around it instead. The
bug has existed at least since .NET 1.1.
Sincerly,
Sune Foldager
Edlund A/