1
Graphics / Highlight text while cursor over it
« on: November 11, 2022, 06:01:05 am »
I'd like to implement a feature where text is highlighted when the mouse is positioned over it. However the only way I can think to do it is to set the color when the cursor is inside the box then reset the color when not.
This works but now is setting the text color every frame. Is there a more efficient way to do this or is the performance hit small enough to where it doesn't matter?
Text text;
text.setString("Test");
//do text setting stuff
while (window.isOpen)
{
if (cursor positioned in text box) text.setFillColor(Color::Red);
else text.setFillColor(Color::White);
//draw stuff
}
text.setString("Test");
//do text setting stuff
while (window.isOpen)
{
if (cursor positioned in text box) text.setFillColor(Color::Red);
else text.setFillColor(Color::White);
//draw stuff
}
This works but now is setting the text color every frame. Is there a more efficient way to do this or is the performance hit small enough to where it doesn't matter?