Skip to content

Commit 5ac0249

Browse files
committed
fix: Press arrow keys will dismiss current word
1 parent 983837b commit 5ac0249

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
description = "Bộ gõ tiếng Việt mã nguồn mở đa hệ điều hành Gõ Key"
33
edition = "2021"
44
name = "goxkey"
5-
version = "0.2.1"
5+
version = "0.2.2"
66

77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
88

@@ -33,4 +33,4 @@ copyright = "Copyright (c) Huy Tran 2023. All rights reserved."
3333
icon = ["icons/icon.icns", "icons/icon.png"]
3434
identifier = "com.goxkey.app"
3535
name = "GoKey"
36-
version = "0.2.0"
36+
version = "0.2.2"

src/main.rs

+8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use platform::{
1717
};
1818

1919
use ui::{UIDataAdapter, UPDATE_UI};
20+
use crate::platform::{RAW_ARROW_DOWN, RAW_ARROW_LEFT, RAW_ARROW_RIGHT, RAW_ARROW_UP};
2021

2122
static UI_EVENT_SINK: OnceCell<ExtEventSink> = OnceCell::new();
2223
const APP_VERSION: &str = env!("CARGO_PKG_VERSION");
@@ -109,6 +110,13 @@ fn event_handler(handle: Handle, pressed_key: Option<PressedKey>, modifiers: Key
109110
toggle_vietnamese();
110111
return true;
111112
}
113+
if raw_keycode == RAW_ARROW_UP || raw_keycode == RAW_ARROW_DOWN {
114+
INPUT_STATE.new_word();
115+
}
116+
if raw_keycode == RAW_ARROW_LEFT || raw_keycode == RAW_ARROW_RIGHT {
117+
// TODO: Implement a better cursor tracking on each word here
118+
INPUT_STATE.new_word();
119+
}
112120
}
113121
PressedKey::Char(keycode) => {
114122
if INPUT_STATE.is_enabled() {

src/platform/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ pub use os::SystemTray;
1717
pub use os::SystemTrayMenuItemKey;
1818

1919
pub const RAW_KEY_GLOBE: u16 = 0xb3;
20+
pub const RAW_ARROW_DOWN: u16 = 0x7d;
21+
pub const RAW_ARROW_UP: u16 = 0x7e;
22+
pub const RAW_ARROW_LEFT: u16 = 0x7b;
23+
pub const RAW_ARROW_RIGHT: u16 = 0x7c;
2024
pub const KEY_ENTER: char = '\x13';
2125
pub const KEY_SPACE: char = '\u{0020}';
2226
pub const KEY_TAB: char = '\x09';

0 commit comments

Comments
 (0)