Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

is window maximized? #400

Open
tizu69 opened this issue Dec 15, 2023 · 9 comments
Open

is window maximized? #400

tizu69 opened this issue Dec 15, 2023 · 9 comments

Comments

@tizu69
Copy link

tizu69 commented Dec 15, 2023

how do I get this

@asticode
Copy link
Owner

This information is not accessible through this lib

@tizu69
Copy link
Author

tizu69 commented Dec 16, 2023

how would I implement a maximize/restore button then

@packet-sent
Copy link

@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

@tizu69
Copy link
Author

tizu69 commented Dec 17, 2023

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

@packet-sent
Copy link

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

@tizu69
Copy link
Author

tizu69 commented Dec 21, 2023

thanks!

@tizu69 tizu69 closed this as completed Dec 21, 2023
@tizu69
Copy link
Author

tizu69 commented Dec 21, 2023

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 tizu69 reopened this Dec 21, 2023
@tizu69
Copy link
Author

tizu69 commented Dec 28, 2023

I'm assuming this isn't possible?

@packet-sent
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants