diff --git a/cosmic-settings/src/app.rs b/cosmic-settings/src/app.rs index 510e963b..d2ef5d52 100644 --- a/cosmic-settings/src/app.rs +++ b/cosmic-settings/src/app.rs @@ -30,7 +30,7 @@ use cosmic::{ iced::{ self, Length, Subscription, event::{self, PlatformSpecific}, - window, + keyboard, window, }, prelude::*, surface, @@ -160,6 +160,7 @@ pub enum Message { #[cfg(feature = "wayland")] PanelConfig(CosmicPanelConfig), SearchActivate, + SearchActivateWith(String), SearchChanged(String), SearchClear, SearchSubmit, @@ -300,8 +301,7 @@ impl cosmic::Application for SettingsApp { daytime, ))) }), - #[cfg(feature = "wayland")] - event::listen_with(|event, _, _id| match event { + event::listen_with(|event, status, _id| match event { #[cfg(feature = "wayland")] iced::Event::PlatformSpecific(PlatformSpecific::Wayland( wayland::Event::Output(wayland::OutputEvent::Created(Some(info)), o), @@ -310,6 +310,13 @@ impl cosmic::Application for SettingsApp { iced::Event::PlatformSpecific(PlatformSpecific::Wayland( wayland::Event::Output(wayland::OutputEvent::Removed, o), )) => Some(Message::OutputRemoved(o)), + iced::Event::Keyboard(keyboard::Event::KeyPressed { + key: keyboard::Key::Character(c), + modifiers: m, + .. + }) if status == event::Status::Ignored && !m.control() && !m.alt() && !m.logo() => { + Some(Message::SearchActivateWith(c.to_string())) + } _ => None, }), #[cfg(feature = "wayland")] @@ -357,9 +364,10 @@ impl cosmic::Application for SettingsApp { return self.search_changed(phrase); } - Message::SearchActivate => { - self.search_active = true; - return cosmic::widget::text_input::focus(self.search_id.clone()); + Message::SearchActivate => return self.on_search(), + + Message::SearchActivateWith(phrase) => { + return self.on_search().chain(self.search_changed(phrase)); } Message::SearchClear => {