mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-11 15:07:08 +00:00
feat: add window title api
This commit is contained in:
parent
67766c7b59
commit
6eaad850ee
2 changed files with 15 additions and 0 deletions
|
@ -57,6 +57,13 @@ impl DesktopContext {
|
||||||
pub fn focus(&self) {
|
pub fn focus(&self) {
|
||||||
let _ = self.proxy.send_event(UserWindowEvent::FocusWindow);
|
let _ = self.proxy.send_event(UserWindowEvent::FocusWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// set window title
|
||||||
|
pub fn title(&self, title: &str) {
|
||||||
|
let _ = self
|
||||||
|
.proxy
|
||||||
|
.send_event(UserWindowEvent::Title(String::from(title)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// use this function can get the `DesktopContext` context.
|
/// use this function can get the `DesktopContext` context.
|
||||||
|
|
|
@ -321,6 +321,12 @@ pub fn launch_with_props<P: 'static + Send>(
|
||||||
window.set_focus();
|
window.set_focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
UserWindowEvent::Title(content) => {
|
||||||
|
for webview in desktop.webviews.values() {
|
||||||
|
let window = webview.window();
|
||||||
|
window.set_title(&content);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Event::MainEventsCleared => {}
|
Event::MainEventsCleared => {}
|
||||||
|
@ -338,6 +344,8 @@ pub enum UserWindowEvent {
|
||||||
DragWindow,
|
DragWindow,
|
||||||
CloseWindow,
|
CloseWindow,
|
||||||
FocusWindow,
|
FocusWindow,
|
||||||
|
|
||||||
|
Title(String),
|
||||||
Minimize(bool),
|
Minimize(bool),
|
||||||
Maximize(bool),
|
Maximize(bool),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue