To reprodue:
-Add a RadMenu with several items and sub items.
-Add shortcuts for some of the sub items (e.g. CTRL + SHIFT + A).
-Run the application and press CTRL + SHIFT + A. As a result the Click event for the specific items is fired. This is correct behavior.
-If you add a RadButton, which Click event shows a RadMessageBox and display the message box before pressing CTRL + SHIFT + A, the Click event for the certain item is fired again, although the main form is currently not active.
Workaround:
public class CustomRadMenuItem : RadMenuItem
{
public CustomRadMenuItem(string text) : base(text)
{
}
protected override Type ThemeEffectiveType
{
get
{
return typeof(RadMenuItem);
}
}
protected override bool CanHandleShortcut(ShortcutEventArgs e)
{
Control owner = this.OwnerControl;
if (owner == null)
{
return false;
}
Form form = owner.FindForm();
if (form == null)
{
RadDropDownMenu toolTipOwner = owner as RadDropDownMenu;
if (toolTipOwner != null && toolTipOwner.Owner != null)
{
form = ((RadMenuElement)this.Owner).ElementTree.Control.FindForm();
if (form != null)
{
Form activeForm = e.FocusedControl == null ? Form.ActiveForm : e.FocusedControl.FindForm();
return form == activeForm || form.ContainsFocus;
}
}
}
return base.CanHandleShortcut(e);
}
}