1
Graphics / sf::Text displaying square
« on: June 21, 2017, 02:58:26 am »
Hi, I have this code:
When I press Return with this code, the Text goes to the next line but also writes a square at the beginning of the line.
If I comment the conditions which calls write(), no square is printed.
So why am I getting this strange behaviour?
Code: [Select]
void TextEditor::handleEvent(const sf::Event& p_event)
{
if(p_event.type == sf::Event::KeyPressed && p_event.key.code == sf::Keyboard::Return)
addLine();
else if(p_event.type == sf::Event::TextEntered)
write(p_event);
}
void TextEditor::addLine()
{
sf::String s(m_text.getString())
s += "\n";
m_text.setString(s);
}
void TextEditor::write(const sf::Event& p_event)
{
sf::String s(m_text.getString());
if(p_event.key.code != sf::Keyboard::BackSpace && p_event.key.code != sf::Keyboard::Return)
s += static_cast<char>(p_event.text.unicode);
m_text.setString(s);
}
When I press Return with this code, the Text goes to the next line but also writes a square at the beginning of the line.
If I comment the conditions which calls write(), no square is printed.
So why am I getting this strange behaviour?