Package tripleplay.ui

Class Menu

All Implemented Interfaces:
Iterable<Element<?>>
Direct Known Subclasses:
PagedMenu

public class Menu extends Elements<Menu>
Holds a collection of MenuItems, dispatching a itemTriggered() signal when one is selected and triggered. Normally used in conjunction with MenuHost to popup the menu (in its own Root), manage animations, track user input, and handle cancellation.

Note that a menu can contain arbitrary Elements, but only those that are MenuItems are eligible for triggering. Changes to the children of previously added Elements instances are tracked using Elements.childAdded() and Elements.childRemoved().

Note about Container types other than Elements: it is assumed that the children of such containers will NOT change after addition to the menu. Such changes will result in undefined behavior, potentially including memory leaks. Scroller, for example, is safe to use since it has exactly one child element that doesn't change. TODO: support escape key to cancel; probably in MenuHost TODO: support/implement full screen menus - this is probably what most phone apps will want

  • Field Details

    • FADE_IN

      public static Menu.AnimFn FADE_IN
      Generic animation to fade in a menu using the layer alpha.
    • FADE_OUT

      public static Menu.AnimFn FADE_OUT
      Generic animation to fade out a menu using the layer alpha.
    • OPENER

      public static Style<Menu.AnimFn> OPENER
      The opening animation function for the menu.
    • CLOSER

      public static Style<Menu.AnimFn> CLOSER
      The closing animation function for the menu.
  • Constructor Details

    • Menu

      public Menu(Layout layout)
      Creates a new menu using the given layout for its elements.
    • Menu

      public Menu(Layout layout, Styles styles)
      Creates a new menu using the given layout and styles.
    • Menu

      public Menu(Layout layout, Style.Binding<?>... styles)
      Creates a new menu using the given layout and style bindings.
  • Method Details

    • deactivated

      public react.SignalView<Menu> deactivated()
      Gets the signal that is dispatched when the menu is closed and no longer usable. This occurs if an item is triggered or if the menu is manually cancelled (using deactivate()).
    • activate

      public void activate()
      Opens this menu, using an animation created by the resolved OPENER style. Once the animation is finished, the user can view the MenuItem choices. When one is selected and dispatched via the itemTriggered() signal, the menu is deactivated automatically.
    • deactivate

      public void deactivate()
      Closes this menu, using an animation created by the resolved CLOSER style. This is normally called automatically when the user clicks off the menu or triggers one of its MenuItems. After the animation is complete, the deactivated() signal will be dispatched.
    • itemTriggered

      public react.SignalView<MenuItem> itemTriggered()
      Gets the signal that is dispatched when a menu item is selected.