feat: add focus api

This commit is contained in:
mrxiaozhuox committed 2022-01-31 19:44:40 +08:00
1 parent 366cf75887
commit 7ca92be015
2 files changed
+12

No files matched your search

+5
View File
@@ -52,6 +52,11 @@ impl DesktopContext {
pub fn close(&self) {
let _ = self.proxy.send_event(UserWindowEvent::CloseWindow);
}
/// set window to focus
pub fn focus(&self) {
let _ = self.proxy.send_event(UserWindowEvent::FocusWindow);
}
}
/// use this function can get the `DesktopContext` context.
+7
View File
@@ -313,6 +313,12 @@ pub fn launch_with_props<P: 'static + Send>(
window.set_maximized(state);
}
}
UserWindowEvent::FocusWindow => {
for webview in desktop.webviews.values() {
let window = webview.window();
window.set_focus();
}
}
}
}
Event::MainEventsCleared => {}
@@ -329,6 +335,7 @@ pub enum UserWindowEvent {
Update,
DragWindow,
CloseWindow,
FocusWindow,
Minimize(bool),
Maximize(bool),
}