aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorArne Dußin2021-02-05 10:35:03 +0100
committerArne Dußin2021-02-05 10:35:03 +0100
commit6b52a88dad43467ae0ea23e96248e934a995570b (patch)
tree1c7dccad68cc56633a88323fa3135a7dbb0898d8 /src
parentfb596a4e3b6dd414241f9525e7efe200949428d6 (diff)
downloadgraf_karto-6b52a88dad43467ae0ea23e96248e934a995570b.tar.gz
graf_karto-6b52a88dad43467ae0ea23e96248e934a995570b.zip
Fix the right char not being used on input
Diffstat (limited to 'src')
-rw-r--r--src/client/gui/dimension_indicator.rs2
-rw-r--r--src/client/input/mod.rs12
2 files changed, 10 insertions, 4 deletions
diff --git a/src/client/gui/dimension_indicator.rs b/src/client/gui/dimension_indicator.rs
index 7d5fd65..d6af690 100644
--- a/src/client/gui/dimension_indicator.rs
+++ b/src/client/gui/dimension_indicator.rs
@@ -162,9 +162,7 @@ impl DimensionIndicator {
match key {
// Add a decimal point to the dimension if possible.
'.' => {
- println!("Adding dec point?");
if !edited_dim.contains('.') {
- println!("Adding dec point!");
edited_dim.push('.');
}
// Nothing changed here, since there is an implicit .0 at the end.
diff --git a/src/client/input/mod.rs b/src/client/input/mod.rs
index e8b1821..26d39c6 100644
--- a/src/client/input/mod.rs
+++ b/src/client/input/mod.rs
@@ -29,6 +29,7 @@ use crate::math::{ExactSurface, Rect, Vec2};
use crate::stable_vec::StableVec;
use raylib::ffi::KeyboardKey;
use raylib::RaylibHandle;
+use raylib_sys::GetCharPressed;
use std::collections::HashMap;
use std::sync::mpsc::{self, Receiver, Sender};
@@ -64,10 +65,17 @@ impl Input {
Some('\n')
} else if rl.is_key_pressed(KeyboardKey::KEY_ESCAPE) {
Some('\x1B')
+ } else if rl.is_key_pressed(KeyboardKey::KEY_TAB) {
+ Some('\t')
} else if rl.is_key_pressed(KeyboardKey::KEY_BACKSPACE) {
Some('\x7f')
} else {
- rl.get_key_pressed_number().map(|c| c as u8 as char)
+ let c_opt = unsafe { GetCharPressed() };
+ if c_opt > 0 {
+ Some(c_opt as u8 as char)
+ } else {
+ None
+ }
};
/* Send the character to the listening entity or push it to the text that
@@ -75,7 +83,7 @@ impl Input {
*/
if let Some(text_pipe) = self.text_pipe.as_mut() {
if let Some(c) = c {
- if text_pipe.send(c).is_err() {
+ if text_pipe.send(dbg!(c)).is_err() {
self.last_text.push(c);
self.text_pipe = None;
}