@NullMarked public class ButtonGuiElement extends BaseInputGuiElement<BaseStyles,ButtonGuiElement>
ButtonGuiElement is a BaseInputGuiElement that allows users to interact via clicking the button or using keyboard shortcuts.
  • Constructor Details

    • ButtonGuiElement

      public ButtonGuiElement()
      Creates a ButtonGuiElement and adds default event listeners for handling disabled states and when the Key.SPACE key is pressed.
  • Method Details

    • renderContent

      public void renderContent(Renderer renderer)
      Description copied from class: GuiElement
      Method to render the main content of the gui element (not borders, backgrounds, etc.).
      Specified by:
      renderContent in class GuiElement<BaseStyles,ButtonGuiElement>
      Parameters:
      renderer - the Renderer instance
    • calculateContentDimensions

      public @Nullable GuiElementDimensions calculateContentDimensions()
      Description copied from class: GuiElement
      Calculates content dimensions for this element. If its dimensions are derived from only its children then it should return null.
      Specified by:
      calculateContentDimensions in class GuiElement<BaseStyles,ButtonGuiElement>
      Returns:
      the dimensions of the content of this element or null if only children dimensions matter
    • setOnAction

      public ButtonGuiElement setOnAction(Runnable onAction)
      Sets the action that fires when the button is interacted with.
      Parameters:
      onAction - the action to execute on button interaction
      Returns:
      this