Skip to content

feat: type to search #1237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions cosmic-settings/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use cosmic::{
iced::{
self, Length, Subscription,
event::{self, PlatformSpecific},
window,
keyboard, window,
},
prelude::*,
surface,
Expand Down Expand Up @@ -160,6 +160,7 @@ pub enum Message {
#[cfg(feature = "wayland")]
PanelConfig(CosmicPanelConfig),
SearchActivate,
SearchActivateWith(String),
SearchChanged(String),
SearchClear,
SearchSubmit,
Expand Down Expand Up @@ -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),
Expand All @@ -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")]
Expand Down Expand Up @@ -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 => {
Expand Down