Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [Solved] Issue with Keypress and sf::Key::Back  (Read 2519 times)

0 Members and 1 Guest are viewing this topic.

drakelord

  • Newbie
  • *
  • Posts: 22
    • View Profile
[Solved] Issue with Keypress and sf::Key::Back
« on: June 30, 2009, 02:05:07 am »
Ok, so, I have an editable text field that people can type into.  Text works fine.  The issue is the backspace key.

If someone presses it once, it works fine and does its job.  One character is removed from the string and properly displayed.  However, any other backspace presses after this do nothing until another displayable key is entered.  

Code: [Select]
if(GameEventsMenu.Key.Code == sf::Key::Back)
{
std::wstring tempstring = MenuSheets[2]->MenuEditTexts[SelectChoice].GetText();
if(tempstring.empty() == false)
tempstring.erase(tempstring.size() - 1);
MenuSheets[2]->MenuEditTexts[SelectChoice].SetText(tempstring.c_str());
}

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
[Solved] Issue with Keypress and sf::Key::Back
« Reply #1 on: June 30, 2009, 07:51:57 am »
You mean that you don't receive the key event from SFML?
Laurent Gomila - SFML developer

drakelord

  • Newbie
  • *
  • Posts: 22
    • View Profile
[Solved] Issue with Keypress and sf::Key::Back
« Reply #2 on: June 30, 2009, 04:49:26 pm »
Well, I just did a test.  I added code to the event that spawns a message box upon receiving the backspace key event.  The message box does spawn each time, meaning that the event is being received.  This means that for some reason, the string isn't updating properly.  Hmm.

drakelord

  • Newbie
  • *
  • Posts: 22
    • View Profile
[Solved] Issue with Keypress and sf::Key::Back
« Reply #3 on: June 30, 2009, 07:21:28 pm »
I found the problem.  After it removed the character, it was inserting an invisible character (unicode 8) representing backspace, that wasn't actually displaying.  Fixed.  Hurray.