By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,892 Members | 1,251 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,892 IT Pros & Developers. It's quick & easy.

Multiple hot key selection

P: n/a
I have a ContextMenu that begs to have hot keys. I tried adding some but am
having issues understanding how to properly manage the events when dealing
with more than one key pressed (e.g., Alt-F1, Cntr-C) or even with F2. Can
someone point me to some documentation that explains how to properly handle
these type of keyboard inputs in ContextMenus?
--
Steve
Nov 16 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
If you are using the MenuItem controls, there is a "shortcut" property that
will take just about anything and trigger selection of that menu item. If
you set it through VS Properties box, you can just select from a list.
Otherwise, there is an enum called "Shortcut" that you can use for this (in
System.Windows.Forms, I think.)

If you want to handle everything manually, you'd probably need to use the
ProcessCmdKey(). Code inside would look something like this:

switch (keyData)
{
case Keys.F3:
HandleF3Press();
return true;
case Keys.Control | Keys.Up
HandleCtrlUpArrow();
return true;
case Keys.Alt | Keys.D1:
HandleAltOne();
return true;
default:
return base.ProcessCmdKey(ref msg, keyData);
}
"Steve Teeples" <St**********@discussions.microsoft.com> wrote in message
news:78**********************************@microsof t.com...
I have a ContextMenu that begs to have hot keys. I tried adding some but am having issues understanding how to properly manage the events when dealing
with more than one key pressed (e.g., Alt-F1, Cntr-C) or even with F2. Can someone point me to some documentation that explains how to properly handle these type of keyboard inputs in ContextMenus?
--
Steve

Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.