[mac] events updates

This commit is contained in:
Lea Anthony 2024-09-08 20:14:45 +10:00
commit 7fafee8a6c
4 changed files with 11 additions and 8 deletions

View file

@ -21,6 +21,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [windows] Window class name option by [windom](https://github.com/windom/) in [#3682](https://github.com/wailsapp/wails/pull/3682)
- Services have been expanded to provide plugin functionality. By [atterpac](https://github.com/atterpac) and [leaanthony](https://github.com/leaanthony) in [#3570](https://github.com/wailsapp/wails/pull/3570)
### Changed
- Events API change: `On`/`Emit` -> user events, `OnApplicationEvent` -> Application Events `OnWindowEvent` -> Window Events, by [leaanthony](https://github.com/leaanthony)
### Fixed
- [linux] Fixed linux compile error introduced by IgnoreMouseEvents addition by [atterpac](https://github.com/atterpac) in [#3721](https://github.com/wailsapp/wails/pull/3721)
- [windows] Fixed syso icon file generation bug by [atterpac](https://github.com/atterpac) in [#3675](https://github.com/wailsapp/wails/pull/3675)

View file

@ -221,7 +221,7 @@ func (m *macosApp) setApplicationMenu(menu *Menu) {
func (m *macosApp) run() error {
// Add a hook to the ApplicationDidFinishLaunching event
m.parent.On(events.Mac.ApplicationDidFinishLaunching, func(*ApplicationEvent) {
m.parent.OnApplicationEvent(events.Mac.ApplicationDidFinishLaunching, func(*ApplicationEvent) {
C.setApplicationShouldTerminateAfterLastWindowClosed(C.bool(m.parent.options.Mac.ApplicationShouldTerminateAfterLastWindowClosed))
C.setActivationPolicy(C.int(m.parent.options.Mac.ActivationPolicy))
C.activateIgnoringOtherApps()

View file

@ -13,7 +13,7 @@ func (m *macosApp) setupCommonEvents() {
for sourceEvent, targetEvent := range commonApplicationEventMap {
sourceEvent := sourceEvent
targetEvent := targetEvent
m.parent.On(sourceEvent, func(event *ApplicationEvent) {
m.parent.OnApplicationEvent(sourceEvent, func(event *ApplicationEvent) {
event.Id = uint(targetEvent)
applicationEvents <- event
})

View file

@ -1240,7 +1240,7 @@ func (w *macosWebviewWindow) run() {
w.setURL(startURL)
// We need to wait for the HTML to load before we can execute the javascript
w.parent.On(events.Mac.WebViewDidFinishNavigation, func(_ *WindowEvent) {
w.parent.OnWindowEvent(events.Mac.WebViewDidFinishNavigation, func(_ *WindowEvent) {
InvokeAsync(func() {
if options.JS != "" {
w.execJS(options.JS)
@ -1254,7 +1254,7 @@ func (w *macosWebviewWindow) run() {
} else {
// We have to wait until the window is shown before we can remove the shadow
var cancel func()
cancel = w.parent.On(events.Mac.WindowDidBecomeKey, func(_ *WindowEvent) {
cancel = w.parent.OnWindowEvent(events.Mac.WindowDidBecomeKey, func(_ *WindowEvent) {
w.setHasShadow(!options.Mac.DisableShadow)
cancel()
})
@ -1263,18 +1263,18 @@ func (w *macosWebviewWindow) run() {
})
// Translate ShouldClose to common WindowClosing event
w.parent.On(events.Mac.WindowShouldClose, func(_ *WindowEvent) {
w.parent.OnWindowEvent(events.Mac.WindowShouldClose, func(_ *WindowEvent) {
w.parent.emit(events.Common.WindowClosing)
})
// Translate WindowDidResignKey to common WindowLostFocus event
w.parent.On(events.Mac.WindowDidResignKey, func(_ *WindowEvent) {
w.parent.OnWindowEvent(events.Mac.WindowDidResignKey, func(_ *WindowEvent) {
w.parent.emit(events.Common.WindowLostFocus)
})
w.parent.On(events.Mac.WindowDidResignMain, func(_ *WindowEvent) {
w.parent.OnWindowEvent(events.Mac.WindowDidResignMain, func(_ *WindowEvent) {
w.parent.emit(events.Common.WindowLostFocus)
})
w.parent.On(events.Mac.WindowDidResize, func(_ *WindowEvent) {
w.parent.OnWindowEvent(events.Mac.WindowDidResize, func(_ *WindowEvent) {
w.parent.emit(events.Common.WindowDidResize)
})