feat: add focus api
This commit is contained in:
1 parent
366cf75887
commit
7ca92be015
2 files changed
+12
No files matched your search
@@ -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.
|
||||
|
||||
@@ -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),
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user