asticode/go-astilectron

is window maximized?

Opened this issue · 9 comments

how do I get this

This information is not accessible through this lib

how would I implement a maximize/restore button then

@tizu69 You can create buttons on your frontend that can send a command to Go via astilectron.sendMessage and read them via a message handler in Go.

go-astilectron-bootstrap can help with this as it provides with a simple way to read the message received and process them with your own handler.

The following snippets should help you if you use go-astilectron-bootstrap and need some frontend buttons to do certain actions such as hiding/closing a window:

//JS
astilectron.sendMessage({
  name: "minimize",
}, function (message) {
  console.log("Closed " + message)
});
//GO
window.Hide() //to hide the window
window.Minimize() //to minimize the window

image
image

I also figured that out by not, but I'm not sure how to implement a button that maximizes or restores the window, depending on if it's currently maximized

I also figured that out by not, but I'm not sure how to implement a button that maximizes or restores the window, depending on if it's currently maximized

@tizu69 you can check the current status of the window with the following (got it from the docs and tested it works in my app):

const { BrowserWindow } = require("electron").remote;
var win = BrowserWindow.getFocusedWindow();
if (win.isMaximized()) {
  console.log("window is maximized")
} else {
    console.log("window not maximized")
}

image

thanks!

hol up, I actually got an issue. Remote isn't available for the version of electron anymore that I'm forced to use (due to Chromium version requirement), so I was told to use the @electron/remote package, but this requires init:

image

is there a way to init this from go-astilectron?

All I'd need is to run that one snippet in the main function and I should be good to go.

I'm assuming this isn't possible?

You could maybe install the library into astilectron and try to call the library from your app's JS or maybe run the navbar code through a preload.js that is loaded in via Go.

I am not 100% sure on which solution will work as I don't use the latest electron due to some issues I get with go-astilectron.
image