mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-09-03 11:17:56 +00:00
correct text handling in SDL2
This commit is contained in:
20
control.cpp
20
control.cpp
@@ -32,6 +32,19 @@ EX int slider_x;
|
||||
EX function <void(int sym, int uni)> keyhandler = [] (int sym, int uni) {};
|
||||
EX function <bool(SDL_Event &ev)> joyhandler = [] (SDL_Event &ev) {return false;};
|
||||
|
||||
#if CAP_SDL2
|
||||
EX void ignore_text(const SDL_TextInputEvent&) {}
|
||||
EX function <void(const SDL_TextInputEvent&)> texthandler = ignore_text;
|
||||
#endif
|
||||
|
||||
EX void reset_handlers() {
|
||||
keyhandler = [] (int sym, int uni) {};
|
||||
joyhandler = [] (SDL_Event &ev) {return false;};
|
||||
#if CAP_SDL2
|
||||
texthandler = ignore_text;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if HDR
|
||||
// what part of the compass does 'skip turn'
|
||||
static constexpr auto SKIPFAC = .4;
|
||||
@@ -1162,6 +1175,12 @@ EX void handle_event(SDL_Event& ev) {
|
||||
}
|
||||
}
|
||||
|
||||
#if CAP_SDL2
|
||||
if(ev.type == SDL_TEXTINPUT) {
|
||||
texthandler(ev.text);
|
||||
}
|
||||
#endif
|
||||
|
||||
dialog::handleZooming(ev);
|
||||
|
||||
if(sym == SDLK_F1 && normal && playermoved)
|
||||
@@ -1318,6 +1337,7 @@ EX void handle_event(SDL_Event& ev) {
|
||||
if(sym || uni) {
|
||||
if(need_refresh) {
|
||||
just_refreshing = true;
|
||||
reset_handlers();
|
||||
screens.back()();
|
||||
just_refreshing = false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user