Jump to content
  • Advertisement
Sign in to follow this  
GuyWithBeard

Windows Forms - MDI parent/child keypress event issue

This topic is 928 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

 

I have a winforms app consisting of a main form + a number of child forms. The child forms can be floating windows, or they can be docked within the main form. I am using DockPanel Suite for this: http://dockpanelsuite.com/

 

The main form has a menu strip where certain menu items have keyboard shortcuts, eg. the Delete key is the shortcut for the "delete object" menu item.

 

This works well in with all child forms except for one, which has a scintilla.net text editor control inside it. The scintilla control has support built-in for keyboard shortcuts such as Ctrl-C and Delete. When this particular child form is highlighted and the user presses the Delete key to delete the characters to the right of the caret the main form fires the "delete object" menu item in the menu strip of the main form. This is obviously not what I want.

 

What would be the correct way to prevent the main form from firing the keyboard shortcuts in the main form menu strip if that one particular child form is active, ie. to let the text editor component react to the keyboard shortcuts without any other parts of the UI intercepting the events?

 

I have verified that the child control handles the key presses correctly if it is a floating window, in which case the main form is not active when the child form is active. The problem occurs only when the child form is nested inside the main form.

 

Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Actually, I think I came up with something. I override the ProcessCmdKey() method for the main form and have it check if the script child window is active. If it is, and the keys about to be processed are one of the conflicting menu item shortcuts, the the method just returns false. That prevents the shortcut event from being fired.
 
Using this I still need to handle all problematic keyboard shortcuts in the ProcessCmdKey() method, but I think I can live with that for now.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!