ButtonWidgetHelper.ButtonBuilder
com.jsmacrosce.jsmacros.client.api.helper.screen.ButtonWidgetHelper.ButtonBuilder
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
Methods
action
action(MethodWrapper<ButtonWidgetHelper<Button>, IScreen, Object, ?> action): ButtonWidgetHelper.ButtonBuilderSince1.8.4#Parameters:
action: the action to run on activation, ornullfor 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
Returns: the configured action, or
null if none is setheight
Parameters:
height: ignored; the button height remains 20
Returns: this builder
size
Parameters:
width: the button widthheight: ignored; the button height remains 20
Returns: this builder