Is it possible to check if cursor hovering on specific word in text?

What I want to do:
When cursor hovers on specific word in text object you get special variable of the text, and then you can create tooltip.

The possible solution that I have in my head, but will need to have change rich(bitmap maybe…) text code:
Add hover variable expression to this type of line: [text]{tooltip.info}
So, when we hover on “text” we can have tooltip expression string of hovered text.

Sorry for bad explaination, but I’m not quite good with terms and etc.

1 Like

How large of a text are you talking about? A sentence, a paragraph or a full page?

I’m not aware of any events. I might be wrong. More details would help narrow down possible workarounds like using an object for each word or using the x, y to calculate the position.

Hm, it can be large as a full page

Can you explain further? Do you want to read the text or just add hoverable tool tips?

For example I have text that was loaded from json file, and when I hover on specific words I get a tooltip

I don’t know enough about your project. If it’s the same text and you can guarantee that the text will always display the exactly the same on every device then you could place objects at certain places, hide them and when touched they could add another text object as a popup. They would be like hit boxes. I just don’t know enough to guarantee consistent word wrap. I guess if it’s the same font or maybe a bitmap font, it would be exactly the same on any device as long as the bitmap text object was the same size.

20240124_054500

Say the purple boxes were named hitbox and they had an object variable named text.

Cursor or touch is on hitbox
Left mouse button is pressed
Trigger once

Action:
Add text object at hitbox.X() , hitboxY() - 20

You would need to make sure only 1 popup could be added at a time.

The text and hit boxes could be create in the scene or as external layouts or as variables either in the app or a json file.

You could then delete the popup object either after a set time or when the mouse button was released or when the cursor was no longer over it if you don’t want to use a mouse click.

Honesty, that’s all I got. As mentioned earlier. You could calculate the position based on the cursor. I don’t know how that would be done.

Maybe someone else had a better idea.

Sadly, this method won’t work with multilanguage text, because position of text will be different based on language

True. Then I’m stumped. Anyone else have any ideas???

Well, I had a go and failed. I tried to read the text where the mouse cursor was but it only was accurate in a couple of places. The orange box is where I click and then if the purple text displays the wrong thing I jiggled the cursor over the part it did read. There didn’t seem to be a consistent pattern with the read errors.

If it had worked well, then it could have been the starting point for raiguri’s interesting problem.




TextRead

1 Like

Please describe your project. More information might help.

For example, I have a special document that describes creature, in this document player can find some special terms that are used practically in every document, so player can hover on that term and he will get a tooltip that will explain meaning of the term.
In nutshell it can be useful not only for often used terms, but also other extra text that player can read if he want to know more about specified thing, etc.

  1. Use a BBCode text object
  2. Paint the special word with a imperceptible (or not) difference between the other words.
  3. Use the “Read pixel values on screen” extension to detect the RGB values of the CursorX();CursorY() to check whether the word is the hovered one.