From b8a9c3464a7ec4c60073fb4441129fa97b36442a Mon Sep 17 00:00:00 2001 From: Arne Dußin Date: Fri, 8 Jan 2021 16:08:09 +0100 Subject: Fix CLI not capturing keyboard This is not a very nice solution and is due to limitations of raylib. Since I want to change the way input is handled in the future this is an okay solution, but when overhauling the input needs to be changed. --- src/snapping.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/snapping.rs') diff --git a/src/snapping.rs b/src/snapping.rs index 325b62e..ceabf69 100644 --- a/src/snapping.rs +++ b/src/snapping.rs @@ -24,8 +24,8 @@ impl Snapper { } /// Update the grain according to the input the program receives. - pub fn update(&mut self, rl: &mut RaylibHandle) { - if !self.grain_gui.active() && rl.is_key_pressed(KeyboardKey::KEY_G) { + pub fn update(&mut self, rl: &mut RaylibHandle, keyboard_captured: bool) { + if !self.grain_gui.active() && rl.is_key_pressed(KeyboardKey::KEY_G) && !keyboard_captured { self.grain_gui.set_active(true); } @@ -33,13 +33,15 @@ impl Snapper { return; } - self.grain_gui.update(rl); + if !keyboard_captured { + self.grain_gui.update(rl); + } - if rl.is_key_pressed(KeyboardKey::KEY_ENTER) { + if !keyboard_captured && rl.is_key_pressed(KeyboardKey::KEY_ENTER) { self.grain_gui.set_active(false); self.grain = self.grain_gui.value(); self.grain_gui.set_value(self.grain); - } else if rl.is_key_pressed(KeyboardKey::KEY_ESCAPE) { + } else if !keyboard_captured && rl.is_key_pressed(KeyboardKey::KEY_ESCAPE) { self.grain_gui.set_active(false); self.grain_gui.set_value(self.grain); } -- cgit v1.2.3-70-g09d2