Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.16.x] ImageButton Not Displaying Text


urbanxx001
 Share

Recommended Posts

So this seems like a bug, but it could be a drawing issue I'm not aware of. I have an ImageButton and regular Button:

this.func_230480_a_(new ImageButton(xstart + 99, ystart + 18, 70, 16, 156, 0, 21, 
WIDGET_TEXTURES, 256, 256, (p_213070_1_) -> { }, new TranslationTextComponent("Image Button")));

this.func_230480_a_(new Button(xstart + 99, ystart + 18, 70, 20,
        new TranslationTextComponent("Button"), (p_213070_1_) -> { }));

Both textures render fine, however the ImageButton doesn't display text. This is odd considering they both output the same arguments below. I also tried to give the ImageButton text color to see if it would make a difference, but it doesn't.

TranslatableComponent{key='Image Button', args=[], siblings=[], style=Style{ color=null, bold=null, italic=null, underlined=null, strikethrough=null, obfuscated=null, clickEvent=null, hoverEvent=null, insertion=null, font=minecraft:default}}
TranslatableComponent{key='Button', args=[], siblings=[], style=Style{ color=null, bold=null, italic=null, underlined=null, strikethrough=null, obfuscated=null, clickEvent=null, hoverEvent=null, insertion=null, font=minecraft:default}}
Edited by urbanxx001
Link to comment
Share on other sites

The constructor of both of the button you are using passes Button.field_238486_s_ (empty), whereas there won't be any hovered text/tooltip being displayed, so I assume you are talking about the text that is rendered on the button:

ImageButton overrides renderButton and does not call super.renderButton(...) (but Button did), and in Widged#renderButton it draws the title you passed in, therefore ImageButton does not render the title, but Button does.

Edited by poopoodice
  • Thanks 1
Link to comment
Share on other sites

That makes a ton of sense now... it's strange that it's set like that though, if ImageButton has a constructor that accepts text, you would think it would render on the button by default. Normally it just passes StringTextComponent.field_240750_d_ (an empty string), so having another hurdle seems redundant.

Edited by urbanxx001
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.