Jump to content

[1.19.2] How to render a custom tooltip text box


SoLegendary

Recommended Posts

I'm looking to render a tooltip text box like the one you get for hovering over items, eg:

images?q=tbn:ANd9GcSrp04MmeI3oVcvr-y3prl

I know the basics of rendering including usage of poseStack in render events, but I just don't know where I can find a class method that can do this.

I'm also hoping said function includes text formatting (bold, italics, colour, etc.) and (if possible) multiline text wrapping but if I have to write that myself any tips for it would be greatly appreciated.

Link to comment
Share on other sites

2 hours ago, SoLegendary said:

I'm looking to render a tooltip text box like the one you get for hovering over items

Screen#renderTooltip

2 hours ago, SoLegendary said:

I'm also hoping said function includes text formatting (bold, italics, colour, etc.)

Set the style on the passed in components.

2 hours ago, SoLegendary said:

(if possible) multiline text wrapping

In the method mentioned first.

Link to comment
Share on other sites

On 10/20/2022 at 12:52 AM, ChampionAsh5357 said:

Screen#renderTooltip

Set the style on the passed in components.

In the method mentioned first.

Ok cool, I got it working now.

One other feature I would like is rendering icons on the box, inline if possible. Unicode sounds like the most compatible solution but barring that if I could at least get the coordinates that the tooltip box corners are rendered at so I can just blit my own graphics that'd work too.

Link to comment
Share on other sites

On 10/20/2022 at 7:18 PM, SoLegendary said:

One other feature I would like is rendering icons on the box, inline if possible. Unicode sounds like the most compatible solution but barring that if I could at least get the coordinates that the tooltip box corners are rendered at so I can just blit my own graphics that'd work too.

Try it an see, they both sound like plausible solutions. The latter may be better since unicode may not be translated across languages.

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.