Open rewin123 opened 3 days ago
You can make this work currently by either:
Text
node entity per word and then having Taffy layout the words using FlexWrap
and JustifyContent
automatically. Then you can check for clicks on the individual Text
node entity that contains your link. It's easier if the text is a single line, then you only need to split the text into three Text
entities.TextLayoutInfo
for the glyphs you want to be pickable and using the Text
node's GlobalTransform
to transform the glyph coords so that they can be compared to the pointer's position.Both methods are really clumsy and annoying though. It's not very hard to implement a builtin solution for Bevy but there isn't time for it before the 0.15 release I think.
I agree that such functionality can wait. Although its absence leads to ugly code. And I want to try option 1 as a temporary solution. Thanks for the idea.
What problem does this solve or what need does it fill?
Text can accept Pointer events, but TextSpan cannot. I wanted to make a link inside the large text and I can't implement this with multiple Texts because the layout of the text will be bad.
What solution would you like?
Add support to recieve Pointer events for TextSpan
What alternative(s) have you considered?
Provide some other check that the mouse is over a particular TextSpan
Additional context