Replies: 3 comments 4 replies
-
It is not at all possible to enter fullscreen automatically in a browser; the user MUST request the app to enter full screen with some kind of interaction like a button press. See |
Beta Was this translation helpful? Give feedback.
-
Following those code to into full screen immediately when window is opened pub struct Weaver {}
impl App for Weaver {
fn update(&mut self, ctx: &Context, frame: &mut Frame) {}
}
fn main() {
let mut native_options = eframe::NativeOptions::default();
native_options.maximized = true;
eframe::run_native(
"weaver1",
native_options,
Box::new(|creation_context| Box::new(Weaver::default())),
);
}
} |
Beta Was this translation helpful? Give feedback.
-
I used wasm-bindgen to add fullscreen functionality to a button on my UI. This is also locking the orientation, I left that in as most people using fullscreen will probably need that too. #[cfg(target_arch = "wasm32")]
if ui.button("Fullscreen").clicked() {
let Some(window) = web_sys::window() else {
return;
};
let Some(document) = window.document() else {
return;
};
if self.wasm_fullscreen {
let _ = document.exit_fullscreen();
let Ok(screen) = window.screen() else {
return;
};
let _ = screen.orientation().unlock();
self.wasm_fullscreen = false;
} else {
let Some(element) = document.document_element() else {
return;
};
let _ = element.request_fullscreen();
let Ok(screen) = window.screen() else {
return;
};
let _ = screen
.orientation()
.lock(web_sys::OrientationLockType::Landscape);
self.wasm_fullscreen = true;
} And added this to the cargo.toml. web-sys = { version ="0.3.70", features =["Element", "Document", "Window","OrientationLockType", "Screen", "ScreenOrientation"]} |
Beta Was this translation helpful? Give feedback.
-
1: how to make window full screen display in native Application ;
2: how about in WASM ;
Beta Was this translation helpful? Give feedback.
All reactions