Stop Button from taking focus during a keypress or keyup event.
-
I wrote a custom menu control that accepts keyboard movement. I have a form with a button on it. When I click the button I see my menu pop up below the button. The problem is that the focus shifts between the button and the custom control whenever I press an arrow key. How do I keep other controls from stealing focus away from my custom control. I don't want to disable other controls. I want to maintain focus in my custom control I've tried to set the handled and the suppressKeyPress functionality in the event but the button still grabs focus for every other keypress. Any ideas? Thanks, Brad
-
I wrote a custom menu control that accepts keyboard movement. I have a form with a button on it. When I click the button I see my menu pop up below the button. The problem is that the focus shifts between the button and the custom control whenever I press an arrow key. How do I keep other controls from stealing focus away from my custom control. I don't want to disable other controls. I want to maintain focus in my custom control I've tried to set the handled and the suppressKeyPress functionality in the event but the button still grabs focus for every other keypress. Any ideas? Thanks, Brad
I found it... here is the magic override... protected override bool IsInputKey(Keys key) { switch (key) { case Keys.Up: case Keys.Down: case Keys.Right: case Keys.Left: return true; } return base.IsInputKey(key); }