Package jexer.menu

Class TMenu

  • All Implemented Interfaces:
    java.lang.Comparable<TWidget>

    public class TMenu
    extends TWindow
    TMenu is a top-level collection of TMenuItems.
    • Constructor Detail

      • TMenu

        public TMenu​(TApplication parent,
                     int x,
                     int y,
                     java.lang.String label)
        Public constructor.
        Parameters:
        parent - parent application
        x - column relative to parent
        y - row relative to parent
        label - mnemonic menu title. Label must contain a keyboard shortcut (mnemonic), denoted by prefixing a letter with "&", e.g. "&File"
    • Method Detail

      • onMouseDown

        public void onMouseDown​(TMouseEvent mouse)
        Handle mouse button presses.
        Overrides:
        onMouseDown in class TWindow
        Parameters:
        mouse - mouse button event
      • onMouseUp

        public void onMouseUp​(TMouseEvent mouse)
        Handle mouse button releases.
        Overrides:
        onMouseUp in class TWindow
        Parameters:
        mouse - mouse button release event
      • onMouseMotion

        public void onMouseMotion​(TMouseEvent mouse)
        Handle mouse movements.
        Overrides:
        onMouseMotion in class TWindow
        Parameters:
        mouse - mouse motion event
      • onKeypress

        public void onKeypress​(TKeypressEvent keypress)
        Handle keystrokes.
        Overrides:
        onKeypress in class TWindow
        Parameters:
        keypress - keystroke event
      • draw

        public void draw()
        Draw a top-level menu with title and menu items.
        Overrides:
        draw in class TWindow
      • setTitleX

        public void setTitleX​(int titleX)
        Set the menu title X position.
        Parameters:
        titleX - the position
      • getTitleX

        public int getTitleX()
        Get the menu title X position.
        Returns:
        the position
      • getMnemonic

        public MnemonicString getMnemonic()
        Get the mnemonic string.
        Returns:
        the full mnemonic string
      • isContext

        public boolean isContext()
        Get the context flag.
        Returns:
        true if this menu is a right-click context menu
      • setContext

        public void setContext​(boolean context,
                               int x,
                               int y)
        Set the context flag, used to open a context menu at a specific screen position.
        Parameters:
        context - if true, this is a context menu
        x - the screen X position
        y - the screen Y position
      • setContext

        public void setContext​(boolean context)
        Set the context flag.
        Parameters:
        context - if true, this is a context menu
      • addItem

        public TMenuItem addItem​(int id,
                                 java.lang.String label)
        Convenience function to add a menu item.
        Parameters:
        id - menu item ID. Must be greater than 1024.
        label - menu item label
        Returns:
        the new menu item
      • addItem

        public TMenuItem addItem​(int id,
                                 java.lang.String label,
                                 boolean enabled)
        Convenience function to add a menu item.
        Parameters:
        id - menu item ID. Must be greater than 1024.
        label - menu item label
        enabled - default state for enabled
        Returns:
        the new menu item
      • addItem

        public TMenuItem addItem​(int id,
                                 java.lang.String label,
                                 TKeypress key)
        Convenience function to add a custom menu item.
        Parameters:
        id - menu item ID. Must be greater than 1024.
        label - menu item label
        key - global keyboard accelerator
        Returns:
        the new menu item
      • addItem

        public TMenuItem addItem​(int id,
                                 java.lang.String label,
                                 TKeypress key,
                                 boolean enabled)
        Convenience function to add a custom menu item.
        Parameters:
        id - menu item ID. Must be greater than 1024.
        label - menu item label
        key - global keyboard accelerator
        enabled - default state for enabled
        Returns:
        the new menu item
      • addDefaultItem

        public TMenuItem addDefaultItem​(int id)
        Convenience function to add one of the default menu items.
        Parameters:
        id - menu item ID. Must be between 0 (inclusive) and 1023 (inclusive).
        Returns:
        the new menu item
      • addDefaultItem

        public TMenuItem addDefaultItem​(int id,
                                        boolean enabled)
        Convenience function to add one of the default menu items.
        Parameters:
        id - menu item ID. Must be between 0 (inclusive) and 1023 (inclusive).
        enabled - default state for enabled
        Returns:
        the new menu item
      • addSeparator

        public void addSeparator()
        Convenience function to add a menu separator.
      • addSubMenu

        public TSubMenu addSubMenu​(java.lang.String title)
        Convenience function to add a sub-menu.
        Parameters:
        title - menu title. Title must contain a keyboard shortcut, denoted by prefixing a letter with "&", e.g. "&File"
        Returns:
        the new sub-menu
      • resetTabOrder

        protected void resetTabOrder()
        Reset the tab order of children to match their position in the list. Available so that subclasses can re-order their widgets if needed.
        Overrides:
        resetTabOrder in class TWidget