Save file on Cmd+S in editor example
This commit is contained in:
parent
06dc12bfbf
commit
c0a141ab02
1 changed files with 14 additions and 1 deletions
|
|
@ -1,10 +1,14 @@
|
|||
use iced::executor;
|
||||
use iced::keyboard;
|
||||
use iced::theme::{self, Theme};
|
||||
use iced::widget::{
|
||||
button, column, container, horizontal_space, pick_list, row, text,
|
||||
text_editor, tooltip,
|
||||
};
|
||||
use iced::{Alignment, Application, Command, Element, Font, Length, Settings};
|
||||
use iced::{
|
||||
Alignment, Application, Command, Element, Font, Length, Settings,
|
||||
Subscription,
|
||||
};
|
||||
|
||||
use highlighter::Highlighter;
|
||||
|
||||
|
|
@ -147,6 +151,15 @@ impl Application for Editor {
|
|||
}
|
||||
}
|
||||
|
||||
fn subscription(&self) -> Subscription<Message> {
|
||||
keyboard::on_key_press(|key_code, modifiers| match key_code {
|
||||
keyboard::KeyCode::S if modifiers.command() => {
|
||||
Some(Message::SaveFile)
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
}
|
||||
|
||||
fn view(&self) -> Element<Message> {
|
||||
let controls = row![
|
||||
action(new_icon(), "New file", Some(Message::NewFile)),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue