Skip to content

How to manually create a window and manipulate it #2283

Answered by amrbashir
fralonra asked this question in Q&A
Discussion options

You must be logged in to vote

you have to get an app handle or window handle which you can obtain in any hook on the tauri builder.

note: code below doesn't have any arguments just for simplicity, check the urls to see the arguments needed.

tauri::Builder::default()
	.setup(|app|{
		let window = app.create_window(); // https://tauri.studio/en/docs/api/rust/tauri/window/struct.Window#create_window
	})
	.on_page_load(|window, _| {
		let window = window.create_window();
	})
	.run();

or from js you can just use the WebviewWindow constructor

import { WebviewWindow } from "@tauri-apps/api/window";
// or `withGlobalTauri: true` in tauri.conf.json
const { WebviewWindow } = window.__TAURI__.window;

new WebviewWindow() // http…

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
6 replies
@amrbashir
Comment options

@fralonra
Comment options

@amrbashir
Comment options

@fralonra
Comment options

@THEGOLDENPRO
Comment options

Answer selected by amrbashir
Comment options

You must be logged in to vote
1 reply
@FabianLars
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants