mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-08-26 14:32:26 +00:00
update key controller router, init navigation methods
This commit is contained in:
parent
0948a6c93a
commit
b716fb1f78
@ -43,24 +43,42 @@ impl Request {
|
|||||||
let suggestion = Rc::new(Suggestion::build(profile, &entry));
|
let suggestion = Rc::new(Suggestion::build(profile, &entry));
|
||||||
|
|
||||||
entry.add_controller({
|
entry.add_controller({
|
||||||
use gtk::{gdk::Key, glib::Propagation};
|
use gtk::{
|
||||||
fn is_up(k: Key) -> bool {
|
gdk::{Key, ModifierType},
|
||||||
matches!(k, Key::Up | Key::KP_Up | Key::Page_Up | Key::KP_Page_Up)
|
glib::Propagation,
|
||||||
|
};
|
||||||
|
let c = gtk::EventControllerKey::builder().build();
|
||||||
|
c.connect_key_pressed({
|
||||||
|
let entry = entry.clone();
|
||||||
|
let suggestion = suggestion.clone();
|
||||||
|
move |_, k, _, m| {
|
||||||
|
if suggestion.is_visible()
|
||||||
|
&& !matches!(
|
||||||
|
m,
|
||||||
|
ModifierType::SHIFT_MASK
|
||||||
|
| ModifierType::ALT_MASK
|
||||||
|
| ModifierType::CONTROL_MASK
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if matches!(k, Key::Up | Key::KP_Up | Key::Page_Up | Key::KP_Page_Up) {
|
||||||
|
if !suggestion.to_back() {
|
||||||
|
entry.error_bell()
|
||||||
}
|
}
|
||||||
fn is_down(k: Key) -> bool {
|
return Propagation::Stop;
|
||||||
matches!(
|
} else if matches!(
|
||||||
k,
|
k,
|
||||||
Key::Down | Key::KP_Down | Key::Page_Down | Key::KP_Page_Down
|
Key::Down | Key::KP_Down | Key::Page_Down | Key::KP_Page_Down
|
||||||
)
|
) {
|
||||||
|
if !suggestion.to_next() {
|
||||||
|
entry.error_bell()
|
||||||
|
}
|
||||||
|
return Propagation::Stop;
|
||||||
}
|
}
|
||||||
let controller = gtk::EventControllerKey::builder().build();
|
|
||||||
controller.connect_key_pressed(|_, k, _, _| {
|
|
||||||
if is_up(k) || is_down(k) {
|
|
||||||
return Propagation::Stop; // @TODO
|
|
||||||
}
|
}
|
||||||
Propagation::Proceed
|
Propagation::Proceed
|
||||||
|
}
|
||||||
});
|
});
|
||||||
controller
|
c
|
||||||
});
|
});
|
||||||
|
|
||||||
entry.connect_icon_release({
|
entry.connect_icon_release({
|
||||||
|
@ -169,4 +169,21 @@ impl Suggestion {
|
|||||||
pub fn hide(&self) {
|
pub fn hide(&self) {
|
||||||
self.popover.popdown()
|
self.popover.popdown()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn to_back(&self) -> bool {
|
||||||
|
false // @TODO
|
||||||
|
}
|
||||||
|
pub fn to_next(&self) -> bool {
|
||||||
|
false // @TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
// Getters
|
||||||
|
|
||||||
|
pub fn is_visible(&self) -> bool {
|
||||||
|
self.popover.is_visible()
|
||||||
|
}
|
||||||
|
|
||||||
|
/*pub fn total(&self) -> u32 {
|
||||||
|
self.list_store.n_items()
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user