Open Happy-Ferret opened 2 years ago
Right now this is not possible in GO but adding it is not that complex. I just won't have time to work on this anytime time soon though. If you feel like it, I can describe what has to be done so that you can make a PR
Right now this is not possible in GO but adding it is not that complex. I just won't have time to work on this anytime time soon though. If you feel like it, I can describe what has to be done so that you can make a PR
I think I know what needs to be done.
Something similar to w.OpenDevTools()
, I assume?
w.Sticky(astikit.BoolPtr
), perhaps?
Weird. I tried adding the changes that, to the best of my knowledge, are necessary but end up with a no-op.
Any idea what I'm doing wrong?
window.go:
...
// Window event names
const (
...
EventNameWindowCmdSetAlwaysOnTop = "window.cmd.set.always.on.top"
EventNameWindowEventAlwaysOnTopChanged = "window.event.always.on.top.changed"
...
func (w *Window) SetAlwaysOnTop(flag bool) (err error) {
if err = w.ctx.Err(); err != nil {
return
}
w.m.Lock()
w.o.AlwaysOnTop = astikit.BoolPtr(flag)
w.m.Unlock()
_, err = synchronousEvent(w.ctx, w, w.w, Event{Name: EventNameWindowCmdSetAlwaysOnTop, TargetID: w.id, WindowOptions: &WindowOptions{AlwaysOnTop: astikit.BoolPtr(flag)}}, EventNameWindowEventAlwaysOnTopChanged)
return
}
message.go
package desktop
import (
"github.com/asticode/go-astilectron"
"github.com/asticode/go-astilectron-bootstrap"
)
func HandleMessages(w *astilectron.Window, m bootstrap.MessageIn) (payload interface{}, err error) {
switch m.Name {
case "always_on_top":
w.SetAlwaysOnTop(true)
payload = "AlwaysOnTop set"
return
}
return
}
app.js
astilectron.sendMessage(
{ name: "always_on_top", payload: "" },
message => {
console.log("received " + message)
});
You need to update astilectron
(the JS part) as well so that it parses the new window.cmd.set.always.on.top
key 👍
You need to update
astilectron
(the JS part) as well so that it parses the newwindow.cmd.set.always.on.top
key 👍
How do I ensure the correct astilectron js is being used?
I edited the files inside %APPDATA%/
EDIT: NVM. It is being used.
I'd like to dynamically set
AlwaysOnTop
based on a setting inside my app.Is there a way to access the WindowOptions outside the bootstrapping procedure (I've been unable to find it, or rather direct access is private) or will I have to make-do with
require("electron").remote.BrowserWindow.getFocusedWindow().setAlwaysOnTop(bool_value)
from inside JS? I'd rather like to avoid doing it like this.