mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
implement shortcut controller for titan input
This commit is contained in:
parent
6f9c2a950a
commit
39bbfcbdda
1 changed files with 27 additions and 1 deletions
|
|
@ -6,7 +6,11 @@ mod text;
|
|||
|
||||
use control::Control;
|
||||
use file::File;
|
||||
use gtk::{glib::Bytes, Notebook};
|
||||
use gtk::{
|
||||
glib::Bytes,
|
||||
prelude::{DisplayExt, WidgetExt},
|
||||
Notebook,
|
||||
};
|
||||
pub use header::Header;
|
||||
use tab::Tab;
|
||||
use text::Text;
|
||||
|
|
@ -71,6 +75,28 @@ impl Titan for gtk::Box {
|
|||
};
|
||||
|
||||
// Init events
|
||||
text.text_view.add_controller({
|
||||
const SHORTCUT: &str = "<Primary>Return"; // @TODO optional
|
||||
let c = gtk::ShortcutController::new();
|
||||
c.add_shortcut(
|
||||
gtk::Shortcut::builder()
|
||||
.trigger(>k::ShortcutTrigger::parse_string(SHORTCUT).unwrap())
|
||||
.action(>k::CallbackAction::new({
|
||||
let u = control.upload.clone();
|
||||
move |_, _| {
|
||||
if u.is_sensitive() {
|
||||
u.emit_activate();
|
||||
} else {
|
||||
u.display().beep();
|
||||
}
|
||||
gtk::glib::Propagation::Stop
|
||||
}
|
||||
}))
|
||||
.build(),
|
||||
);
|
||||
c
|
||||
});
|
||||
|
||||
control.options.connect_clicked({
|
||||
let text = text.clone();
|
||||
let file = file.clone();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue