fix: set focus
This commit is contained in:
parent
7ffecba549
commit
575311b40d
@ -25,9 +25,16 @@ pub fn run() {
|
|||||||
button_state: MouseButtonState::Up,
|
button_state: MouseButtonState::Up,
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
icon.app_handle()
|
let window = icon.app_handle().get_window("main").unwrap();
|
||||||
.get_window("main").unwrap()
|
if !window.is_visible().unwrap() {
|
||||||
.show().unwrap();
|
window.show().unwrap();
|
||||||
|
}
|
||||||
|
if window.is_minimized().unwrap() {
|
||||||
|
window.unminimize().unwrap();
|
||||||
|
}
|
||||||
|
if !window.is_focused().unwrap() {
|
||||||
|
window.set_focus().unwrap();
|
||||||
|
}
|
||||||
println!("Tray icon clicked");
|
println!("Tray icon clicked");
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
@ -36,13 +43,13 @@ pub fn run() {
|
|||||||
.menu_on_left_click(false)
|
.menu_on_left_click(false)
|
||||||
.on_menu_event(|app, event| match event.id.as_ref() {
|
.on_menu_event(|app, event| match event.id.as_ref() {
|
||||||
"quit" => {
|
"quit" => {
|
||||||
println!("quit menu item was clicked");
|
println!("quit menu item was clicked");
|
||||||
app.exit(0);
|
app.exit(0);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
println!("menu item {:?} not handled", event.id);
|
println!("menu item {:?} not handled", event.id);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.build(app)?;
|
.build(app)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user