[SFML] 텍스트 이벤트
텍스트 이벤트
sf::Event::TextEntered
이렇게 사용할 수 있음..
#include <SFML/Graphics.hpp>
#include <iostream>
int main()
{
sf::RenderWindow window(sf::VideoMode(512,512), "SFML TUTORIAL", sf::Style::Close | sf::Style::Resize);
while (window.isOpen())
{
sf::Event evnt;
while (window.pollEvent(evnt))
{
switch (evnt.type)
{
case sf::Event::TextEntered:
if (evnt.text.unicode < 128)
{
printf("%c", evnt.text.unicode);
}
break;
}
}
}
return 0;
}
아래 사진처럼 윈도우에 입력을 하면 콘솔에 입력한 키가 뜰것이다.
재밌는 점은 백스페이스를 눌러 다시 입력하면 덮어써진다.
Leave a comment