Class UIButton

All Implemented Interfaces:
UIContextActions, UIControlTarget, UIFocus, UIKeyFocus, UIMouseFocus, UITabFocus, UITriggerSource, UITriggerTarget, LXLoopTask
Direct Known Subclasses:
UIButton.Action, UIButton.Toggle, UIButton.Tooltip, UIButton.Trigger, UIMappingButton

public class UIButton extends UIParameterComponent implements UIControlTarget, UITriggerSource, UITriggerTarget, UIFocus
  • Field Details

    • active

      protected boolean active
    • isMomentary

      protected boolean isMomentary
    • inactiveColor

      protected UIColor inactiveColor
    • activeColor

      protected UIColor activeColor
    • enabled

      protected boolean enabled
    • momentaryPressValid

      protected boolean momentaryPressValid
  • Constructor Details

    • UIButton

      public UIButton()
    • UIButton

      public UIButton(float w, BooleanParameter p)
    • UIButton

      public UIButton(float w, float h, BooleanParameter p)
    • UIButton

      public UIButton(float x, float y, float w, float h, BooleanParameter p)
    • UIButton

      public UIButton(float w, EnumParameter<?> p)
    • UIButton

      public UIButton(float w, float h, EnumParameter<?> p)
    • UIButton

      public UIButton(float x, float y, float w, float h, EnumParameter<?> p)
    • UIButton

      public UIButton(float w, float h)
    • UIButton

      public UIButton(float x, float y, float w, float h)
  • Method Details

    • setActiveFontColor

      public UIButton setActiveFontColor(int activeFontColor)
      Sets the active font color
      Parameters:
      activeFontColor - color
      Returns:
      this
    • setActiveFontColor

      public UIButton setActiveFontColor(UIColor activeFontColor)
      Sets the active font color
      Parameters:
      activeFontColor - color
      Returns:
      this
    • setEnabled

      public UIButton setEnabled(boolean enabled)
    • setTriggerable

      public UIButton setTriggerable(boolean triggerable)
    • setIconColor

      public UIButton setIconColor(boolean iconColor)
    • setIconColor

      public UIButton setIconColor(int iconColor)
    • setIconColor

      public UIButton setIconColor(UIColor iconColor)
    • getDescription

      public String getDescription()
      Description copied from class: UIObject
      Objects are encouraged to override this method providing a helpful String displayed to the user explaining the function of this UI component. If no help is available, return null rather than an empty String.
      Overrides:
      getDescription in class UIObject
      Returns:
      Helpful contextual string explaining function of this element
    • getParameter

      public LXListenableNormalizedParameter getParameter()
      Specified by:
      getParameter in class UIParameterComponent
    • removeParameter

      public UIButton removeParameter()
    • setParameter

      public UIButton setParameter(EnumParameter<? extends Object> parameter)
    • setEnumFormatter

      public UIButton setEnumFormatter(UIButton.EnumFormatter formatter)
    • setParameter

      public UIButton setParameter(BooleanParameter parameter)
    • setMomentary

      public UIButton setMomentary(boolean momentary)
    • setIconOffset

      public UIButton setIconOffset(float iconOffsetX, float iconOffsetY)
    • setIconOffsetX

      public UIButton setIconOffsetX(float iconOffsetX)
    • setIconOffsetY

      public UIButton setIconOffsetY(float iconOffsetY)
    • onDraw

      protected 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
    • onBlur

      protected void onBlur()
      Description copied from class: UIObject
      Subclasses override when element loses focus
      Overrides:
      onBlur in class UIObject
    • onMouseDragged

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

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

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

      protected 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
    • onKeyReleased

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

      public boolean isActive()
    • setActive

      public UIButton setActive(boolean active)
    • setActive

      protected UIButton setActive(boolean active, boolean pushToParameter)
    • toggle

      public UIButton toggle()
    • onToggle

      protected void onToggle(boolean active)
      Subclasses may override this to handle changes to the button's state
      Parameters:
      active - Whether button is active
    • onClick

      protected void onClick()
      Subclasses may override when a momentary button is clicked, and the click release happened within the bounds of the box
    • setActiveColor

      public UIButton setActiveColor(int activeColor)
    • setActiveColor

      public UIButton setActiveColor(UIColor activeColor)
    • setInactiveColor

      public UIButton setInactiveColor(int inactiveColor)
    • setInactiveColor

      public UIButton setInactiveColor(UIColor inactiveColor)
    • setLabel

      public UIButton setLabel(String label)
    • setActiveLabel

      public UIButton setActiveLabel(String activeLabel)
    • setInactiveLabel

      public UIButton setInactiveLabel(String inactiveLabel)
    • setIcon

      public UIButton setIcon(VGraphics.Image icon)
    • setActiveIcon

      public UIButton setActiveIcon(VGraphics.Image activeIcon)
    • setInactiveIcon

      public UIButton setInactiveIcon(VGraphics.Image inactiveIcon)
    • setControlSource

      public UIButton setControlSource(LXNormalizedParameter controlSource)
      Sets an explicit control source for the button, which may or may not match its other parameter behavior. Useful for buttons that need to perform a custom LXCommand rather than explicitly change parameter value, but still should be mappable for modulation and MIDI.
      Parameters:
      controlSource - Control source
      Returns:
      this
    • setControlTarget

      public UIButton setControlTarget(LXNormalizedParameter controlTarget)
      Sets an explicit control target for the button, which may or may not match its other parameter behavior. Useful for buttons that need to perform a custom LXCommand rather than explicitly change parameter value, but still should be mappable for modulation and MIDI.
      Parameters:
      controlTarget - Control target
      Returns:
      this
    • getControlTarget

      public LXNormalizedParameter getControlTarget()
      Specified by:
      getControlTarget in interface UIControlTarget
    • getTriggerSource

      public BooleanParameter getTriggerSource()
      Specified by:
      getTriggerSource in interface UITriggerSource
    • getTriggerTarget

      public BooleanParameter getTriggerTarget()
      Specified by:
      getTriggerTarget in interface UITriggerTarget
    • getTriggerSourceParameter

      protected BooleanParameter getTriggerSourceParameter()
    • getTriggerTargetParameter

      protected BooleanParameter getTriggerTargetParameter()
    • dispose

      public void dispose()
      Overrides:
      dispose in class UIObject