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

Author Topic: [SOLVED] Event text unicode  (Read 3763 times)

0 Members and 1 Guest are viewing this topic.

ScArL3T

  • Newbie
  • *
  • Posts: 32
    • View Profile
[SOLVED] Event text unicode
« 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)))
« Last Edit: May 20, 2015, 11:01:09 pm by ScArL3T »

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: [SOLVED] Event text unicode
« Reply #1 on: May 20, 2015, 11:00:00 pm »
Instead of these magic numbers, you should use expressive standard functions in the <cctype> header:
if (std::isalnum(event.text.unicode))
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

ScArL3T

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: [SOLVED] Event text unicode
« Reply #2 on: May 20, 2015, 11:01:35 pm »
Thank you!

 

anything