1
General / sf::Event::TextEntered is repeating Key Events;
« on: March 05, 2019, 07:37:07 am »
Hello all I would like to hopefully get some help with this problem.
Project : This is a personal project to write a simple text editor;
So whenever I press a Key(unicode assigned) it will repeat multiple times heres a list of what I tried and the code :
window.setKeyRepeatEnabled(false);
Used isKeyPressed for real time input vs KeyPressed but produced same output regardless;
// Unknown is caps lock but as of now it seems to not work due to unknown reasons
Tried to switch code to if(sf::Keyboard::keyPressed(Q) && sf::Keyboard::keyPressed(Unknown)){text.setString(input = input + "Q"); std::cout<<"random output" <<std::endl;} // produced no output with Unknown
I then was thinking to put a bool flag so you can't have repetition of characters 1 char away but then that would lead to issues when writing things like last names and etc.
Also this is running from the main loop so I just passed event as reference so thats not the problem;
Here is the code , if anymore is needed I can provide
Project : This is a personal project to write a simple text editor;
So whenever I press a Key(unicode assigned) it will repeat multiple times heres a list of what I tried and the code :
window.setKeyRepeatEnabled(false);
Used isKeyPressed for real time input vs KeyPressed but produced same output regardless;
// Unknown is caps lock but as of now it seems to not work due to unknown reasons
Tried to switch code to if(sf::Keyboard::keyPressed(Q) && sf::Keyboard::keyPressed(Unknown)){text.setString(input = input + "Q"); std::cout<<"random output" <<std::endl;} // produced no output with Unknown
I then was thinking to put a bool flag so you can't have repetition of characters 1 char away but then that would lead to issues when writing things like last names and etc.
Also this is running from the main loop so I just passed event as reference so thats not the problem;
Here is the code , if anymore is needed I can provide
Quote
void Editor::Input(sf::Event& event) {
//if (event.type == sf::Event::TextEntered) { if (event.text.unicode == 113) { text.setString(input = input + "q"); } }
if (sf::Keyboard::isKeyPressed) { if (event.text.unicode == 113) { text.setString(input = input + "q"); } }
if (event.type == sf::Event::TextEntered) { if (event.text.unicode == 119) { text.setString(input = input + "w"); } }
if (event.type == sf::Event::TextEntered) { if (event.text.unicode == 101) { text.setString(input = input + "e"); } }
if (event.type == sf::Event::TextEntered) { if (event.text.unicode == 114) { text.setString(input = input + "r"); } }
if (event.type == sf::Event::TextEntered) { if (event.text.unicode == 116) { text.setString(input = input + "t"); } }
if (event.type == sf::Event::TextEntered) { if (event.text.unicode == 121) { text.setString(input = input + "y"); } }
if (event.type == sf::Event::TextEntered) { if (event.text.unicode == 117) { text.setString(input = input + "u"); } }
if (event.type == sf::Event::TextEntered) { if (event.text.unicode == 105) { text.setString(input = input + "i"); } }
if (event.type == sf::Event::TextEntered) { if (event.text.unicode == 111) { text.setString(input = input + "o"); } }
if (event.type == sf::Event::TextEntered) { if (event.text.unicode == 112) { text.setString(input = input + "p"); } }
}