diff options
| author | Arne Dußin | 2021-01-08 16:08:09 +0100 |
|---|---|---|
| committer | Arne Dußin | 2021-01-08 16:08:09 +0100 |
| commit | b8a9c3464a7ec4c60073fb4441129fa97b36442a (patch) | |
| tree | d1147f7b017e7ff7c0fc4895501fe030b038780a /src/snapping.rs | |
| parent | 60327dd3ef85a263173e6275cb122c9191c030fe (diff) | |
| download | graf_karto-b8a9c3464a7ec4c60073fb4441129fa97b36442a.tar.gz graf_karto-b8a9c3464a7ec4c60073fb4441129fa97b36442a.zip | |
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.
Diffstat (limited to 'src/snapping.rs')
| -rw-r--r-- | src/snapping.rs | 12 |
1 files changed, 7 insertions, 5 deletions
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); } |
