Skip to content

ButtonWidgetHelper.ButtonBuilder ​

com.jsmacrosce.jsmacros.client.api.helper.screen.ButtonWidgetHelper.ButtonBuilder

Since1.8.4

Builds a standard-appearance button bound to the screen that supplied this builder.
Its height is fixed at 20; other properties are configured through the shared builder.

js
const screen = Hud.createScreen("a screen", true);  
screen.setOnInit(JavaWrapper.methodToJava(function (self) {
  self.buttonBuilder()
     .pos(10, 20)
     .size(100, 20)
     .message("press me")
     .action(JavaWrapper.methodToJava(function (btn, onScreen) {
       // the callback is given the button and the screen
       Chat.log(`pressed on the screen titled ${onScreen.getTitleText()}`);  
     }))
     .build();  
}));  
Hud.openScreen(screen);

Nested type declared in ButtonWidgetHelper.

Constructors ​

new ButtonWidgetHelper.ButtonBuilder ​

new ButtonWidgetHelper.ButtonBuilder(IScreen screen)#
Retains the screen associated with this builder for later widget creation.

Parameters:

  • screen: screen associated with the builder

Methods ​

action ​

Parameters:

  • action: the action to run on activation, or null for no action
Returns: this builder

createWidget ​

createWidget(): ButtonWidgetHelper<Button>#
Creates and wraps a new standard-appearance button from this builder's current configuration without adding it to the screen or applying shared post-creation styles. Use build() to create, configure, and add the button.
Returns: the newly wrapped standard-appearance button

getAction ​

getAction(): MethodWrapper<ButtonWidgetHelper<Button>, IScreen, Object, ?>Since1.8.4#
Returns: the configured action, or null if none is set

height ​

height(int height): ButtonWidgetHelper.ButtonBuilderSince1.8.4#

Parameters:

  • height: ignored; the button height remains 20
Returns: this builder

size ​

size(int width, int height): ButtonWidgetHelper.ButtonBuilderSince1.8.4#

Parameters:

  • width: the button width
  • height: ignored; the button height remains 20
Returns: this builder