SFML community forums
Help => General => Topic started by: Njifra on December 02, 2013, 11:02:09 pm
-
I need help with making insertion point.
If anyone doesn't know what is it, it is thingy('|') that appears and then disappears and so on... when you edit or insert text...
I really need help!!!
Thanks!!!
-
You mean the caret? Where are you stuck?
-
For a blinking cursor/insertion point/caret you can use rectangle shape and a clock to time it, but you need to be specific with what you need help. :)
-
Nexus said:
You mean the caret? Where are you stuck?
Yes, caret.
Well I'm making my own textbox, so im stuck at blinking cursor/insertion point/caret...
Charachter size that I'm using is 20...
Font is arial.ttf
Anything more?
For textbox I'm using sprite... It looks pretty awesome, just it is bad without caret, cuz you cant know if u selected textbox or so...
Oh, yes, I use SFML 2.0
-
I meant if you have already tried to implement it, and if there has been a specific problem.
Generally, look at the sf::Text and sf::Glyph classes. With them, you can find out the width of single characters. By comparing the character position with the mouse position, you know where the caret is placed. It requires some thinking, but it shouldn't be extremely difficult.
-
Can I just use sf::Text::getGlobalBound or getLocalBound to get width and height?
-
No, getGlobalBounds() only yields the position of the text's bounding rectangle. You are interested in the positions and sizes of the single characters in the text object.
-
Thanks for help!!!
-
http://www.sfml-dev.org/documentation/2.1/classsf_1_1Text.php#adf120ed4159e43daa782b17fea23ea82
-
Thanks Laurent and Nexus, I made working caret/insertion point, if anyone wants coding, just ask me!!!
:D