I want my app to respond to left arrow and right arrow key. So I wrote
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
The debugger gets confused by the declaration of the Keys enum. Which looks like this:
[Flags]
public enum Keys {
LButton = 1,
ShiftKey = 0x10,
ControlKey = 0x11,
Control = 0x20000,
// And lots more
}
With the [Flags] attribute turned on, the debugger visualizer tries to show the values of the individual bits in keyData
. You pressed the Control key, Keys.ControlKey, whose value is 0x11. The Control flag is turned on because of that so keyData = 0x20011.
So the debugger interprets 0x20011 as bits and makes it 0x20000 | 0x00010 | 0x00001. Which turns into "LButton | ShiftKey | Control". There isn't any good way to make it smarter, other than by using (int)keyData
in the debugger expression. The fundamental issue is the [Flags] attribute on the enum, it is only somewhat appropriate but the vast majority of Keys enum values are not flag values.