Skip to content

Commit 0239fce

Browse files
Filippoossedfloreshz
authored andcommitted
made the text input to get focus when the app is focused
1 parent 6bf1d26 commit 0239fce

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/app.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use cosmic::{
1919
Alignment, Event, Length, Subscription, event,
2020
keyboard::Event as KeyEvent,
2121
keyboard::{Key, Modifiers},
22+
window,
2223
},
2324
theme,
2425
widget::{
@@ -65,6 +66,7 @@ pub enum Message {
6566
Open(String),
6667
SetDecimalComma(bool),
6768
Evaluate,
69+
Window,
6870
}
6971

7072
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq)]
@@ -538,6 +540,9 @@ impl Application for CosmicCalculator {
538540
}
539541
self.nav.clear();
540542
}
543+
Message::Window => {
544+
return widget::text_input::focus(self.input_id.clone());
545+
}
541546
}
542547
Task::batch(tasks)
543548
}
@@ -569,6 +574,7 @@ impl Application for CosmicCalculator {
569574
Event::Keyboard(KeyEvent::ModifiersChanged(modifiers)) => {
570575
Some(Message::Modifiers(modifiers))
571576
}
577+
Event::Window(window::Event::Focused) => Some(Message::Window),
572578
_ => None,
573579
}),
574580
cosmic_config::config_subscription(

0 commit comments

Comments
 (0)