wails icon indicating copy to clipboard operation
wails copied to clipboard

Support Multiple Windows

Open leaanthony opened this issue 1 year ago β€’ 9 comments

Is your feature request related to a problem? Please describe.

We'd like to support multiple windows and improve the current window APIs to support it.

Describe the solution you'd like

A window-centric API eg:

  app := wails.CreateApp(appOptions)
  mainWindow := app.CreateWindow(windowOptions)
  childWindow := mainWindow.CreateWindow(windowOptions)

leaanthony avatar Jun 22 '22 10:06 leaanthony

Can you also support custom dialog windows as an HTML? So that the dialog windows will all match with the application window theme which is already styled in HTML and CSS?

KiddoV avatar Jul 02 '22 17:07 KiddoV

Hey @KiddoV - what's driving this requirement? Is it Webview2 showing light dialogs in dark mode? That's a known bug on their end. If not, please open another ticket so we don't mix up the conversation πŸ‘

leaanthony avatar Jul 02 '22 22:07 leaanthony

@leaanthony no, I was just wondering if we can have a way to customize the dialog boxes like a message box using CSS and HTML. With the help of Wails, we build the app main window with full of HTML and CSS, so , calling a dialog box with the default OS theme seem a bit ...odd.

So, instead of: basic-window This looks better, don't you think? styled-window

I know, I know... that I can make a modal within the webview window and call it done, but having a separate dialog window would be awesome.

KiddoV avatar Jul 03 '22 01:07 KiddoV

Some people wouldn't agree πŸ˜„ but having the option is good.

leaanthony avatar Jul 03 '22 01:07 leaanthony

+1 one app need Multiple Windows

askie avatar Jul 03 '22 13:07 askie

Yes, this would unlock the true potential of wails. πŸ’ͺ I discovered wails today and super pumped to learn and create. Thanks for this excellent effort.

aneeskA avatar Jul 16 '22 15:07 aneeskA

genuinely looking forward to this, something like this would be a lifesaver especially for a screenshotting tool

Deepfried-Chips avatar Jul 28 '22 13:07 Deepfried-Chips

ζœŸεΎ…ζ”―ζŒε€šηͺ—口

skypiaoyizhe avatar Jul 29 '22 05:07 skypiaoyizhe

To support multiple windows, I'm treating each window as a different executable.

My project structure looks like this

--MyApp
--splash.exe //Splash screen. After 5 seconds this screen is automatically closed and the projects screen is opened
--projects.exe //Screen to list saved projects. When a project is selected, the project editing screen opens
--editor.exe //Playground to edit a project

1 - The screens are opened via cmd inside the executables. 2 - With the flag library it is possible to pass custom parameters before execution.

path, _ := os.Getwd()
cmd := exec.Command(path+"\\editor.exe", "-project=xxxx")
...

This is a simple and limited solution, but it suits my use case.

santanamic avatar Sep 06 '22 17:09 santanamic

@santanamic Why didn't I think of this! :)

I tried this just now in my Mac and realised that this created two apps in the taskbar. For example:

image

Do you have a way to make it not do this?

aneeskA avatar Oct 16 '22 14:10 aneeskA

@santanamic To give context, this is what I did to the template app. Please ignore the messy code; it is written to confirm my understanding.

// Greet returns a greeting for the given name
func (a *App) Greet(name string) string {
	dir, err := os.Getwd()
	if err != nil {
		fmt.Println(err.Error())
	}
	fmt.Println("directory=", dir)
	err = exec.Command(dir + "/kuit").Run()
	if err != nil {
		fmt.Println(err.Error())
	}
	return fmt.Sprintf("Hello %s, It's show time!", name)
}

aneeskA avatar Oct 16 '22 14:10 aneeskA

@aneeskA You can open a native webview window.

<a href="#" id="open-popup">open popup</a>

(() => { let id = document.getElementById("open-popup"); id.addEventListener("click", function(event){ let popupWindow = window.open("", 'myWindow', "width=800,height=500,left=283,top=134,location=no,menubar=no,scrollbars=no,resizable=no,status=no,titlebar=no,toolbar=no"); popupWindow.document.write("<html><body>123...</body></html>"); }); })();

The problem is the fixed URL bar

image

window.open accepts some parameters. Most unfortunately don't work.

santanamic avatar Oct 16 '22 17:10 santanamic

@santanamic Why didn't I think of this! :)

I tried this just now in my Mac and realised that this created two apps in the taskbar. For example:

image

Do you have a way to make it not do this?

You can also reopen the current window. πŸ˜…

cmd := exec.Command(path+"\self.exe", "-screen=editor")

The screen argument must receive the name of the view and do the proper logic for execution.

This way it is possible to work with only 1 executable.

I hadn't noticed this simplicity. I believe Multiple Windows support can be based on this? @leaanthony

@aneeskA Please if this runs successfully on the mec let me know.

santanamic avatar Oct 16 '22 20:10 santanamic

Great workaround πŸ‘ Multiple window support will allow more than 1 window to be displayed at once. Is there any reason you prefer to relaunch the app instead of just swapping out the view?

leaanthony avatar Oct 16 '22 20:10 leaanthony

Great workaround πŸ‘ Multiple window support will allow more than 1 window to be displayed at once. Is there any reason you prefer to relaunch the app instead of just swapping out the view?

I need for the following components

1 - Home screen/Splash screen

2 - Custom Dialogs, Configuration Forms and a Log Console

3 - Open a custom HTML outside the main editor

santanamic avatar Oct 17 '22 02:10 santanamic

@aneeskA Please if this runs successfully on the mec let me know.

I just now tried it and it is not working as we expected in my Mac.

aneeskA avatar Oct 17 '22 04:10 aneeskA

Great workaround πŸ‘ Multiple window support will allow more than 1 window to be displayed at once. Is there any reason you prefer to relaunch the app instead of just swapping out the view?

I am not sure if I understood "swapping out the view", but for me I need multiple windows to be able to do separate but related things in different windows something like a browser allows me to do. Put different but related stuff side by side to analyse data.

image

aneeskA avatar Oct 17 '22 04:10 aneeskA

This would be great. I think all I really need is a way to open a window with window options that opens to a particular HTML file. A way to control the window would be good too (close it, move it, hide it, etc).

I'd mainly be using these for displaying logs alongside the main application, giving the user a way to provide more information (like a form), and customize the main app (like an options pane).

I think it'll be useful if windows have access to other windows, so for example the new window could change what the main window is doing.

mholt avatar Oct 19 '22 01:10 mholt

I want to have two web views in one window, allowing me to show an external website. Many sites block iframe usage, and I assume that's true with something like Wails.

I have two use cases. One use case is a live-reload app that will run a Go web app and rebuild, then reload it when something changes. This is possible with an iframe but doesn't allow me to read things like the page title or to use JavaScript to reload the page. The workaround is to use a reverse proxy. The other is a hacker news client, where I'd like to show the comments with the linked external website.

I can move this comment elsewhere if this is out of scope for Multi-Windows.

SamHennessy avatar Oct 19 '22 03:10 SamHennessy

@mholt - I think this will be fairly trivial once we refactor out the current window code and make it more programmatic, as per the system tray API. I imagine this being something like:

logWindow := application.NewWindow(...)

// Store wherever you want

logWindow.Resize() // etc

leaanthony avatar Oct 19 '22 07:10 leaanthony

@SamHennessy I'd make that a different request. I think you're wanting more flexibility around containers within the same window?

leaanthony avatar Oct 19 '22 07:10 leaanthony

I have another use case. I am pushing windows to another embedded wayland compositor and I would like to share state between them in goland. Multiple windows could allow me to manage everything from a single runtime.

I could use a single view but I will need to manage window properties and focus as there are other wayland surfaces that are rendering other applications..

jaunkst avatar Nov 16 '22 21:11 jaunkst

So I want to port a web app I was working on to Wails. One of my use cases is the ability to enter markdown in text areas. But I also provide the ability to edit the markdown in a full blown editor window that launches as a separate named tab and writes the result to local storage and sends a closed event to the launching tab when done. Then the launching tab fetches the modified markdown and replaces the text area with the new markdown. Being able to launch a separate editor window that allows communication between the two windows would be fantastic.

steowens avatar Dec 21 '22 09:12 steowens

Hey @steowens - this is absolutely happening but be aware that the current API is really geared around 1 window, and that affects everything. For multiple windows, there will unavoidably be an API change but that's a good thing! I have some exciting things to announce soon so stick around πŸ‘

leaanthony avatar Dec 21 '22 09:12 leaanthony

support multiple windows +1

dmwin72015 avatar Jan 18 '23 01:01 dmwin72015

Please Support multiple Windows:

import useChildWindow from "../wailsjs/go/main/App.js";

// the window uses a piniaStore for data exchange
let details = useChildWindow('details.vue', windowOptions);

function onShowDetails() {
  details.show();
} 

Korny666 avatar Jan 19 '23 13:01 Korny666

PLZ Support multiple Windows:

import useChildWindow from "../wailsjs/go/main/App.js";

// the window uses a piniaStore for data exchange
let details = useChildWindow('details.vue', windowOptions);

function onShowDetails() {
  details.show();
} 

What's PLT?

megozhang avatar Jan 27 '23 12:01 megozhang

PLZ Support multiple Windows:

import useChildWindow from "../wailsjs/go/main/App.js";

// the window uses a piniaStore for data exchange
let details = useChildWindow('details.vue', windowOptions);

function onShowDetails() {
  details.show();
} 

What's PLT?

I think you mean PLZ? PLZ is please in internet slang

Korny666 avatar Jan 30 '23 08:01 Korny666

PLZ Support multiple Windows:

import useChildWindow from "../wailsjs/go/main/App.js";

// the window uses a piniaStore for data exchange
let details = useChildWindow('details.vue', windowOptions);

function onShowDetails() {
  details.show();
} 

What's PLT?

I think you mean PLZ? PLZ is please in internet slang

haha~,Thank you!

megozhang avatar Feb 01 '23 11:02 megozhang

May I ask if there are any new developments?

sohaha avatar Mar 26 '23 08:03 sohaha