Class UISliderKnob

All Implemented Interfaces:
UIKeyHandler, Hintable, Savable

public class UISliderKnob extends UIContainer
Defines the knob (aka slider or scrubber) on a slider. Generally created by UISlider directly.
  • Field Details

    • _position

      protected float _position
      The current relative position of the knob handle, as a percent.
  • Method Details

    • getKnobLabel

      public UILabel getKnobLabel()
      Returns:
      the UILabel that represents the handle of the knob
    • getPosition

      public float getPosition()
      Returns:
      the current position (as a percent) of the knob handle [0.0, 1.0]
    • setPosition

      public void setPosition(float newPosition)
      Sets the current position of the knob handle
      Parameters:
      newPosition - the new position as a percent [0.0, 1.0]
    • layout

      public void layout()
      Description copied from class: UIComponent
      Override this to perform actual layout.
      Overrides:
      layout in class UIContainer
    • getSliderFrontEdge

      protected int getSliderFrontEdge()
      Returns:
      the relative location (x or y) of the leading edge of the knob handle. An x value if the we are horizontal or a y value if we are vertical. This is used for various mouse interactions.
    • attachedToHud

      public void attachedToHud()
      Description copied from class: UIComponent
      Override to provide an action to take when this component or its top level component are attached to a UIHud.
      Overrides:
      attachedToHud in class UIContainer
    • detachedFromHud

      public void detachedFromHud()
      Description copied from class: UIComponent
      Override to provide an action to take just before this component or its top level component are removed from a UIHud.
      Overrides:
      detachedFromHud in class UIContainer
    • setEnabled

      public void setEnabled(boolean enabled)
      Overrides:
      setEnabled in class UIComponent
      Parameters:
      enabled - true if this component should be considered "enabled"... a concept that is interpreted by each individual component type.
    • mousePressed

      public boolean mousePressed(MouseButton button, InputState state)
      Enable clicking in slider to step the knob one way or the other.
      Overrides:
      mousePressed in class UIComponent
      Parameters:
      button - the button that was pressed
      state - the current tracked state of the input system.
      Returns:
      true if we want to consider the event "consumed" by the UI system.