Completed
Last Updated: 14 Jun 2014 06:46 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 25 Apr 2014 09:03
Category:
Type: Bug Report
0
FIX. RadMenu - Shortcuts for sub items should not be processed when the main forms is not active
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);
    }
}

0 comments