mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-09-11 14:32:00 +00:00
create key map helpers
This commit is contained in:
parent
16dcd19cd0
commit
0948a6c93a
@ -44,17 +44,18 @@ impl Request {
|
|||||||
|
|
||||||
entry.add_controller({
|
entry.add_controller({
|
||||||
use gtk::{gdk::Key, glib::Propagation};
|
use gtk::{gdk::Key, glib::Propagation};
|
||||||
|
fn is_up(k: Key) -> bool {
|
||||||
|
matches!(k, Key::Up | Key::KP_Up | Key::Page_Up | Key::KP_Page_Up)
|
||||||
|
}
|
||||||
|
fn is_down(k: Key) -> bool {
|
||||||
|
matches!(
|
||||||
|
k,
|
||||||
|
Key::Down | Key::KP_Down | Key::Page_Down | Key::KP_Page_Down
|
||||||
|
)
|
||||||
|
}
|
||||||
let controller = gtk::EventControllerKey::builder().build();
|
let controller = gtk::EventControllerKey::builder().build();
|
||||||
controller.connect_key_pressed(|_, k, _, _| {
|
controller.connect_key_pressed(|_, k, _, _| {
|
||||||
if k == Key::Down
|
if is_up(k) || is_down(k) {
|
||||||
|| k == Key::KP_Down
|
|
||||||
|| k == Key::Page_Down
|
|
||||||
|| k == Key::KP_Page_Down
|
|
||||||
|| k == Key::Up
|
|
||||||
|| k == Key::KP_Up
|
|
||||||
|| k == Key::Page_Up
|
|
||||||
|| k == Key::KP_Page_Up
|
|
||||||
{
|
|
||||||
return Propagation::Stop; // @TODO
|
return Propagation::Stop; // @TODO
|
||||||
}
|
}
|
||||||
Propagation::Proceed
|
Propagation::Proceed
|
||||||
|
Loading…
x
Reference in New Issue
Block a user