Just have a:
std::string buffer;
And on events:
if(Event.Type == sf::Event::TextEntered){
std::string tmp;
tmp+= static_cast<char>(Event.Text.Unicode);
buffer.append(tmp);
}
When drawing it, something like:
sf::Text a;
a.SetString(buffer);
sf::RenderWindow::Draw(a);
You might wanna tweak it to handle Enter/return, backspace etc differently.
Event.Key.Code's for :
Backspace = 8
Enter/return = 13
Edit: More complete example wich supports deleting strings and event on return:
if(Event.Type == sf::Event::TextEntered){
switch(Event.Key.Code){
case 8:
// Remove last character if pressed 8(backspace)
if(buffer.size()> 0){
buffer.erase(buffer.begin()+buffer.size()-1);
}
break;
case 13:
// When press enter, do stuff:
DoStuff();
break;
default:
// Not backspace or enter? Append character to bufferstring!
std::string tmp;
tmp+= static_cast<char>(Event.Text.Unicode);
buffer.append(tmp);
break;
}
}