how to create a text cursor in sfml

I want to create a text cursor, but i don't know how to properly, I've made a simple one, but it breaks when long characters like √ are in the sf::Text, how do i implement it properly? I've been suggested to use sf::Font::getGlyph()::bounds in combo with sf::Text::findCharacterPos(), but i don't know how it could help. <- try out this video, jump to time 29:28 to see them show the results of their textbox code.
I haven't watched the whole video, but they seem to do a pretty thorough walk-through.
@newbieg, I've watched it but the text cursor isn't really a text cursor, as it can't go to any point in the text except the end, which makes it more of a decoration than anything
what i need is to find if the mouse is touching a glyphs rectangle and the glyph's information

Last edited on
sf::Text::findCharacterPos gives you the position of a character.

sf::Font::getGlyph gives you the size of the character.

If you know the position where the click was made it should be possible to use the above information to calculate which character that is clicked (or is closest). I haven't tried but it seems like it should be possible.
Last edited on
Topic archived. No new replies allowed.