From 2d6a5cae5e1e9eff2f3964c3a5888aaede38707e Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Thu, 12 Jan 2023 21:52:02 -0500 Subject: [PATCH] Use events instead of isKeyPressed for the interrupt key Also related to #291 --- src/game/boe.actions.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/game/boe.actions.cpp b/src/game/boe.actions.cpp index 90706ef4..80b8f824 100644 --- a/src/game/boe.actions.cpp +++ b/src/game/boe.actions.cpp @@ -3128,12 +3128,16 @@ bool is_sign(ter_num_t ter) { bool check_for_interrupt(){ using kb = sf::Keyboard; bool interrupt = false; + sf::Event evt; + if(mainPtr.pollEvent(evt) && evt.type == sf::Event::KeyPressed) { + // TODO: I wonder if there are other events we should handle here? Resize maybe? #ifdef __APPLE__ - if((kb::isKeyPressed(kb::LSystem) || kb::isKeyPressed(kb::RSystem)) && kb::isKeyPressed(kb::Period)) - interrupt = true; + if(evt.key.code == kb::Period && evt.key.system) + interrupt = true; #endif - if((kb::isKeyPressed(kb::LControl) || kb::isKeyPressed(kb::RControl)) && kb::isKeyPressed(kb::C)) - interrupt = true; + if(evt.key.code == kb::C && evt.key.control) + interrupt = true; + } if(interrupt) { cChoiceDlog confirm("confirm-interrupt", {"quit","cancel"}); if(confirm.show() == "quit") return true;