Skip to content

ButtonWidgetHelper.TexturedButtonBuilder ​

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

Since1.8.4

Builds a texture-based button bound to the screen that supplied this builder.
Provide textures for the enabled, disabled, enabled-focused, and disabled-focused states; none falls back to another. Its height is fixed at 20.

js
const screen = Hud.createScreen("a screen", true);  
screen.setOnInit(JavaWrapper.methodToJava(function (self) {
 self.texturedButtonBuilder()
    .pos(10, 20)
    .size(100, 20)
    .enabledTexture("minecraft:item/diamond")
    .disabledTexture("minecraft:item/emerald")
    .enabledFocusedTexture("minecraft:item/diamond")
    .disabledFocusedTexture("minecraft:item/emerald")
    .build();  
}));  
Hud.openScreen(screen);

Nested type declared in ButtonWidgetHelper.

Constructors ​

new ButtonWidgetHelper.TexturedButtonBuilder ​

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

Parameters:

  • screen: screen associated with the builder

Methods ​

action ​

Sets the action run when the button is activated; pass null to clear it.

Parameters:

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

createWidget ​

Creates and wraps a new texture-based 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 texture-based button

disabledFocusedTexture ​

disabledFocusedTexture(Identifier disabledFocused): ButtonWidgetHelper.TexturedButtonBuilderSince1.9.0#
Sets the texture used when the button is inactive and hovered or focused.

Parameters:

  • disabledFocused: the texture to draw while disabled and focused
Returns: this builder
disabledFocusedTexture(String disabledFocused): ButtonWidgetHelper.TexturedButtonBuilderSince1.9.3#
Sets the disabled, focused texture from its resource-location string; an omitted namespace defaults to minecraft.

Parameters:

  • disabledFocused: the texture to draw while disabled and focused
Returns: this builder

disabledTexture ​

disabledTexture(Identifier disabled): ButtonWidgetHelper.TexturedButtonBuilderSince1.9.0#
Sets the texture used when the button is inactive and neither hovered nor focused.

Parameters:

  • disabled: the texture to draw while disabled
Returns: this builder
disabledTexture(String disabled): ButtonWidgetHelper.TexturedButtonBuilderSince1.9.3#
Sets the disabled, unfocused texture from its resource-location string; an omitted namespace defaults to minecraft.

Parameters:

  • disabled: the texture to draw while disabled
Returns: this builder

enabledFocusedTexture ​

enabledFocusedTexture(Identifier enabledFocused): ButtonWidgetHelper.TexturedButtonBuilderSince1.9.0#
Sets the texture used when the button is active and hovered or focused.

Parameters:

  • enabledFocused: the texture to draw while enabled and focused
Returns: this builder
enabledFocusedTexture(String enabledFocused): ButtonWidgetHelper.TexturedButtonBuilderSince1.9.3#
Sets the enabled, focused texture from its resource-location string; an omitted namespace defaults to minecraft.

Parameters:

  • enabledFocused: the texture to draw while enabled and focused
Returns: this builder

enabledTexture ​

enabledTexture(Identifier enabled): ButtonWidgetHelper.TexturedButtonBuilderSince1.9.0#
Sets the texture used when the button is active and neither hovered nor focused.

Parameters:

  • enabled: the texture to draw while enabled and not focused
Returns: this builder
enabledTexture(String enabled): ButtonWidgetHelper.TexturedButtonBuilderSince1.9.3#
Sets the enabled, unfocused texture from its resource-location string; an omitted namespace defaults to minecraft.

Parameters:

  • enabled: the texture to draw while enabled and not focused
Returns: this builder

getAction ​

Returns: the configured action, or null if none is set

height ​

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

Parameters:

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

size ​

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

Parameters:

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