[BP] How to approach making a custom tooltip widget for a list of static/unchanging text widgets?

Preface: I’m using UE 5.4

Hey there, I’m working a game at the moment and I’ve come across an obstacle in the form of making custom tooltips for a stats screen. The issue seemed simple enough to fix, but I think I’ve run into more confusion than I’m willing to bare. I’ve looked through several tutorials and they all give varying information, all of which led me in different directions and so I’m here looking for a more specific answer to my issue, but I digress.


What I have:
A basic UI Widget that holds a stat window with several user widget text boxes (the “Text” field of the user widgets is set to editable and has indeed already been adjusted for each text widget in the main UI), as well as text widgets that are part of the main UI that show character stats (no problem with these).

A widget for the “stat label” text with a simple event structure to expose the text to the main UI blueprint (this is the original widget of the user widget instances in the first image).
image

A simple tooltip widget that has text widget exposed as a variable, and the text field bound to a text variable, to be set as a description.

I have created a struct + data table that holds data about; the stats label text widget’s name (which is set in the editor already, so kind of redundant); and the tooltip description which is what should populate the tooltip that gets created when hovering over one of the user widget text boxes.



What I need:
I need to be able to set the text of the tooltip widget (stat label’s description, in this case) created when hovered over the instanced text widget. But I’m not sure which way to approach this, or if I’m doing this wrong or in some convoluted way.

Initially I had set out to do everything in the main widget itself (apart from the tooltip widget itself, which would bind to each text widget in the main UI) but was later put under the impression that things should be modular and use instances of a single widget within a parent widget (in this case, with my main UI). So currently have I have a hierarchy of Main UI > Stats Label Text Widget > Tooltip Widget but I presume this is the wrong way to go about it.

Thing is, the text for these tooltips will never change. The stat labels will always remain the same, the tooltips are just there to give additional information, so is it even worth making this stuff modular?
Do I even need to use a struct and data table for this? Am I overcomplicating this? I’m having trouble wrapping my head around the logic because I’m not sure what is absolutely necessary to make this work and what is avoidable.

I was going to assume you are doing this for stylistic reasons (control of how the tooltip looks), but just in case: Built in tooltips? (widget props, in behaviour cat).

The datatable you have could certainly be used, but that implies you will be creating and destroying widgets dynamically; Personally I would avoid this as it does indeed seem over complicated.

Assuming the default tooltips are no good for you, I would just put the tooltip text in with the label text, and bind its visibility with the label’s IsHovered(). Once setup, it just works and you need touch nothing in code, which is always nice.

Thanks for the reply!
That’s right, I just want to customize the visual of the tooltip, for the most part. Nothing fancy.
And fair enough. I had a suspicion that the struct/data table was not necessary but I couldn’t quite make heads or tails of whether there were other (better? cleaner?) ways of getting/setting tooltip text per-text label.

I was thinking of doing an IsHovered check, but with the way I had things set up, I think I made that impossible since things were instanced and I wasn’t able to set hover events anywhere meaningfully. I’m going to rework it all so it’s in the base UI again (except for the tooltip widget, of course) and feed the widget the information from the main UI, possibly with an IsHovered check.

Turns out the solution was much simpler than I thought!

Here’s how I ended up doing it:

I got rid of the “Label Text” widget and redid all the text widgets as part of the main UI, each one with Is variable set to true. In the graph editor I used the On Initialized event and made each variable-ed text widget as part of an array (Ignore the Set Visibility node, that’s unrelated).

I bound each text widget’s Tool Tip Widget property to a single, simple function; ShowTooltip.


This function does a for loop for each element on the array when the tooltip function is called. If a particular element is hovered, it takes that element’s Tool Tip Text field (where I wrote the description text) and sends its contents to a newly-created custom tooltip widget!

Also note that the Tooltip widget has a simple function to set its Text field.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.