SFML community forums

Help => System => Topic started by: ScArL3T on May 20, 2015, 10:37:20 pm

Title: [SOLVED] Event text unicode
Post by: ScArL3T on May 20, 2015, 10:37:20 pm
So i have this code:
case sf::Event::TextEntered:
c = static_cast<char>(event.text.unicode);
break;
 

My question is, how do I make this ignore keys that are not letters?

edit: bad englando

For anyone interested this is the solution:
if (((event.text.unicode > 64) && (event.text.unicode < 91)) || ((event.text.unicode > 96) && (event.text.unicode < 123)))
Title: Re: [SOLVED] Event text unicode
Post by: Nexus on May 20, 2015, 11:00:00 pm
Instead of these magic numbers, you should use expressive standard functions in the <cctype> header (http://en.cppreference.com/w/cpp/header/cctype):
if (std::isalnum(event.text.unicode))
Title: Re: [SOLVED] Event text unicode
Post by: ScArL3T on May 20, 2015, 11:01:35 pm
Thank you!