go-astilectron icon indicating copy to clipboard operation
go-astilectron copied to clipboard

is window maximized?

Open tizu69 opened this issue 1 year ago • 9 comments

how do I get this

tizu69 avatar Dec 15 '23 15:12 tizu69

This information is not accessible through this lib

asticode avatar Dec 15 '23 17:12 asticode

how would I implement a maximize/restore button then

tizu69 avatar Dec 16 '23 08:12 tizu69

@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

packet-sent avatar Dec 16 '23 19:12 packet-sent

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 avatar Dec 17 '23 12:12 tizu69

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

packet-sent avatar Dec 17 '23 19:12 packet-sent

thanks!

tizu69 avatar Dec 21 '23 15:12 tizu69

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.

tizu69 avatar Dec 21 '23 21:12 tizu69

I'm assuming this isn't possible?

tizu69 avatar Dec 28 '23 20:12 tizu69

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

packet-sent avatar Dec 28 '23 22:12 packet-sent