basis for ensuring keybindings turn off when editing things
This commit is contained in:
parent
ab88791d80
commit
3d1d0f84ba
26
src/main.rs
26
src/main.rs
|
@ -264,14 +264,6 @@ impl cosmic::Application for App {
|
||||||
nav = nav.max_width(280);
|
nav = nav.max_width(280);
|
||||||
}
|
}
|
||||||
|
|
||||||
// let dnd = DndDestination::new(
|
|
||||||
// nav,
|
|
||||||
// vec!["application/service-item".to_string().into()],
|
|
||||||
// )
|
|
||||||
// .data_received_for(|item| {
|
|
||||||
// cosmic::app::Message::App(Message::DndDrop(item))
|
|
||||||
// });
|
|
||||||
|
|
||||||
let column = column![
|
let column = column![
|
||||||
text::heading("Service List").center().width(280),
|
text::heading("Service List").center().width(280),
|
||||||
nav
|
nav
|
||||||
|
@ -361,14 +353,14 @@ impl cosmic::Application for App {
|
||||||
// debug!(?event);
|
// debug!(?event);
|
||||||
match event {
|
match event {
|
||||||
iced::Event::Keyboard(event) => match event {
|
iced::Event::Keyboard(event) => match event {
|
||||||
iced::keyboard::Event::KeyPressed {
|
iced::keyboard::Event::KeyReleased {
|
||||||
key,
|
key,
|
||||||
modifiers,
|
modifiers,
|
||||||
..
|
..
|
||||||
} => Some(Message::Key(key, modifiers)),
|
} => Some(Message::Key(key, modifiers)),
|
||||||
_ => None,
|
_ => None,
|
||||||
},
|
},
|
||||||
iced::Event::Mouse(event) => None,
|
iced::Event::Mouse(_event) => None,
|
||||||
iced::Event::Window(window_event) => {
|
iced::Event::Window(window_event) => {
|
||||||
match window_event {
|
match window_event {
|
||||||
window::Event::CloseRequested => {
|
window::Event::CloseRequested => {
|
||||||
|
@ -388,10 +380,10 @@ impl cosmic::Application for App {
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iced::Event::Touch(event) => None,
|
iced::Event::Touch(_touch) => None,
|
||||||
iced::Event::A11y(id, action_request) => None,
|
iced::Event::A11y(_id, _action_request) => None,
|
||||||
iced::Event::Dnd(dnd_event) => None,
|
iced::Event::Dnd(_dnd_event) => None,
|
||||||
iced::Event::PlatformSpecific(platform_specific) => {
|
iced::Event::PlatformSpecific(_platform_specific) => {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -755,7 +747,11 @@ where
|
||||||
presenter::Message::PrevSlide,
|
presenter::Message::PrevSlide,
|
||||||
)),
|
)),
|
||||||
(Key::Character(k), _) if k == *"q" => {
|
(Key::Character(k), _) if k == *"q" => {
|
||||||
self.update(Message::Quit)
|
if !self.song_editor.editing() {
|
||||||
|
self.update(Message::Quit)
|
||||||
|
} else {
|
||||||
|
Task::none()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_ => Task::none(),
|
_ => Task::none(),
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ pub enum Message {
|
||||||
ChangeTitle(String),
|
ChangeTitle(String),
|
||||||
ChangeVerseOrder(String),
|
ChangeVerseOrder(String),
|
||||||
ChangeLyrics(text_editor::Action),
|
ChangeLyrics(text_editor::Action),
|
||||||
|
Edit(bool),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SongEditor {
|
impl SongEditor {
|
||||||
|
@ -84,6 +85,7 @@ impl SongEditor {
|
||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
Message::ChangeTitle(title) => {
|
Message::ChangeTitle(title) => {
|
||||||
|
debug!(title);
|
||||||
self.title = title;
|
self.title = title;
|
||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
|
@ -95,6 +97,11 @@ impl SongEditor {
|
||||||
self.lyrics.perform(action);
|
self.lyrics.perform(action);
|
||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
|
Message::Edit(edit) => {
|
||||||
|
debug!(edit);
|
||||||
|
self.editing = edit;
|
||||||
|
Task::none()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,6 +126,7 @@ impl SongEditor {
|
||||||
let title_input = text_input("song", &self.title)
|
let title_input = text_input("song", &self.title)
|
||||||
.on_input(Message::ChangeTitle)
|
.on_input(Message::ChangeTitle)
|
||||||
.label("Song Title");
|
.label("Song Title");
|
||||||
|
|
||||||
let verse_input = text_input(
|
let verse_input = text_input(
|
||||||
"Verse
|
"Verse
|
||||||
order",
|
order",
|
||||||
|
@ -147,4 +155,8 @@ order",
|
||||||
]);
|
]);
|
||||||
column.into()
|
column.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn editing(&self) -> bool {
|
||||||
|
self.editing
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue