2

I'm trying to add my own functionality for Alt-key shortcuts.

I have a MDIContainer form, and I programatically add new forms (each with just a RichTextBox) as child forms at runtime. I then add custom handlers to the newly generated RichTextBoxes.

I've been trying to write the custom RichTextBox KeyUp and/or KeyDown custom handlers such that when the user presses Alt + [some key], my code is executed and the MenuStrip does not gain focus. I've had no success.

For example, if the user presses Alt+A while the RichTextBox has focus, I want certain code executed. The code doesn't get executed, and instead the main MenuStrip gains focus. This is pretty much the exact opposite of what I'm looking for.

Other code in the KeyUp and KeyDown handlers are being executed, so I can be sure that my methods are actually handling the events; I just can't seem to prevent to MenuStrip from grabbing focus when Alt-key combinations are pressed...

RapierMother
  • 339
  • 1
  • 3
  • 13
  • use control key combinations. Alt is a system key. – Ňɏssa Pøngjǣrdenlarp May 19 '14 at 18:02
  • 2
    Please don't answer other peoples' well-thought-out questions with "give up on what you're trying to do, and do insead." Not only would your suggested "solution" not fit the needs of my project, but you don't even know what you're talking about: "Alt is a system key"? Seriously? As if that somehow has any bearing. Any keypress can be intercepted. – RapierMother May 28 '14 at 11:45
  • "well thought out"? I think not. People expect the Alt key to do certain things like activate menus or fire shortcut keys. Doing otherwise makes garage built apps non compliant with Windows standards. Quoting from it: `Avoid ALT+ letter combinations because they may conflict with access keys.` Which is why you dont see such an idiom in use much - if at all. Of course, any keypress can be processed, no one said otherwise. You may have to resort to lower level things like message filters or hooks because you want to supress/hide the keystroke from Windows/NET. – Ňɏssa Pøngjǣrdenlarp May 28 '14 at 12:26
  • If you actuslly read the question, I think you'll find it's clearly well-thought-out. As well, you'll find that expectations have nothing to do with it. As you can see, I'm trying to break expectations of the Alt key, not set them. The issue was solved by another user, while you were spouting rhetoric. Thanks for your time, though. – RapierMother May 28 '14 at 13:04

0 Answers0