Class UIContextButton

All Implemented Interfaces:
UIFocus, UIKeyFocus, UIMouseFocus, UITabFocus, LXLoopTask

public class UIContextButton extends UI2dComponent implements UIFocus
  • Constructor Details

    • UIContextButton

      public UIContextButton(UI ui, float x, float y, float w, float h)
    • UIContextButton

      public UIContextButton(UI ui, float x, float y, float w, float h, UI2dComponent contextMenu)
  • Method Details

    • setIcon

      public UIContextButton setIcon(VGraphics.Image icon)
    • setIconOffset

      public UIContextButton setIconOffset(float iconOffsetX, float iconOffsetY)
    • getContextMenu

      public UI2dComponent getContextMenu()
      Accessor for the underlying context menu object
      Returns:
      Context menu object opened by this button
    • setContextMenuWidth

      public UIContextButton setContextMenuWidth(float contextMenuWidth)
      Sets the width of the context menu opened by this button
      Parameters:
      contextMenuWidth - Width of context menu
      Returns:
      this
    • setContextActions

      public UIContextButton setContextActions(UIContextActions.Action[] contextActions)
      Sets an array of actions that will be shown in the context menu that opens when the button is clicked
      Parameters:
      contextActions - Set of context actions shown when button is clicked
      Returns:
      this
    • setLabel

      public UIContextButton setLabel(String label)
      Sets the label visible on the button
      Parameters:
      label - Label
      Returns:
      this
    • setDirection

      public UIContextButton setDirection(UIContextButton.Direction direction)
      Sets the direction in which the context menu opens
      Parameters:
      direction - Direction to open
      Returns:
      this
    • onDraw

      public void onDraw(UI ui, VGraphics vg)
      Description copied from class: UI2dComponent
      Subclasses should override this method to perform their drawing functions.
      Overrides:
      onDraw in class UI2dComponent
      Parameters:
      ui - UI context
      vg - Graphics context
    • onMousePressed

      public void onMousePressed(MouseEvent mouseEvent, float mx, float my)
      Description copied from class: UIEventHandler
      Subclasses override to receive mouse events
      Overrides:
      onMousePressed in class UIEventHandler
      Parameters:
      mouseEvent - Mouse event
      mx - x-coordinate
      my - y-coordinate
    • onMouseReleased

      public void onMouseReleased(MouseEvent mouseEvent, float mx, float my)
      Description copied from class: UIEventHandler
      Subclasses override to receive mouse events
      Overrides:
      onMouseReleased in class UIEventHandler
      Parameters:
      mouseEvent - Mouse event
      mx - x-coordinate
      my - y-coordinate
    • onKeyPressed

      public void onKeyPressed(KeyEvent keyEvent, char keyChar, int keyCode)
      Description copied from class: UIEventHandler
      Subclasses override to receive key events
      Overrides:
      onKeyPressed in class UIEventHandler
      Parameters:
      keyEvent - Key event
      keyChar - Key character
      keyCode - Key code value
    • dispose

      public void dispose()
      Overrides:
      dispose in class UIObject