Beispiel #1
0
        /*
         * Post an ACTION_EVENT to the target of the MenuPeer
         * associated with the specified keyboard event (on
         * keydown).  Returns true if there is an associated
         * keyboard event.
         */
        internal virtual bool HandleShortcut(KeyEvent e)
        {
            // Is it a key event?
            int id = e.ID;

            if (id != KeyEvent.KEY_PRESSED && id != KeyEvent.KEY_RELEASED)
            {
                return(false);
            }

            // Is the accelerator modifier key pressed?
            int accelKey = Toolkit.DefaultToolkit.MenuShortcutKeyMask;

            if ((e.Modifiers & accelKey) == 0)
            {
                return(false);
            }

            // Pass MenuShortcut on to child menus.
            int nmenus = MenuCount;

            for (int i = 0; i < nmenus; i++)
            {
                Menu m = GetMenu(i);
                if (m.HandleShortcut(e))
                {
                    return(true);
                }
            }
            return(false);
        }