mirror of
https://github.com/wavetermdev/wails.git
synced 2026-08-05 13:53:43 -07:00
[v3 mac] Fix WindowShouldClose bug
This commit is contained in:
@@ -1188,7 +1188,7 @@ func (w *macosWebviewWindow) run() {
|
||||
|
||||
// Translate ShouldClose to common WindowClosing event
|
||||
w.parent.On(events.Mac.WindowShouldClose, func(_ *WindowEventContext) {
|
||||
w.emit(events.Common.WindowClosing)
|
||||
w.parent.emit(events.Common.WindowClosing)
|
||||
})
|
||||
|
||||
if w.parent.options.HTML != "" {
|
||||
|
||||
@@ -48,6 +48,10 @@ extern bool hasListeners(unsigned int);
|
||||
}
|
||||
@end
|
||||
@implementation WebviewWindowDelegate
|
||||
- (BOOL)windowShouldClose:(NSWindow *)sender {
|
||||
processWindowEvent(self.windowId, EventWindowShouldClose);
|
||||
return false;
|
||||
}
|
||||
- (void) dealloc {
|
||||
// Makes sure to remove the retained properties so the reference counter of the retains are decreased
|
||||
self.leftMouseEvent = nil;
|
||||
@@ -56,7 +60,6 @@ extern bool hasListeners(unsigned int);
|
||||
// Handle script messages from the external bridge
|
||||
- (void)userContentController:(nonnull WKUserContentController *)userContentController didReceiveScriptMessage:(nonnull WKScriptMessage *)message {
|
||||
NSString *m = message.body;
|
||||
|
||||
// TODO: Standardise drag by sending the drag event back to Go
|
||||
if ( [m isEqualToString:@"drag"] ) {
|
||||
/*
|
||||
@@ -373,12 +376,6 @@ extern bool hasListeners(unsigned int);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)windowShouldClose:(NSNotification *)notification {
|
||||
if( hasListeners(EventWindowShouldClose) ) {
|
||||
processWindowEvent(self.windowId, EventWindowShouldClose);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)windowWillBecomeKey:(NSNotification *)notification {
|
||||
if( hasListeners(EventWindowWillBecomeKey) ) {
|
||||
processWindowEvent(self.windowId, EventWindowWillBecomeKey);
|
||||
|
||||
@@ -63,7 +63,7 @@ mac:WindowDidUpdateShadow
|
||||
mac:WindowDidUpdateTitle
|
||||
mac:WindowDidUpdateToolbar
|
||||
mac:WindowDidUpdateVisibility
|
||||
mac:WindowShouldClose
|
||||
mac:WindowShouldClose!
|
||||
mac:WindowWillBecomeKey
|
||||
mac:WindowWillBecomeMain
|
||||
mac:WindowWillBeginSheet
|
||||
|
||||
@@ -178,41 +178,6 @@ func main() {
|
||||
}
|
||||
windowsEventsDecl.WriteString("\t" + eventTitle + " " + eventType + "\n")
|
||||
windowsEventsValues.WriteString("\t\t" + event + ": " + strconv.Itoa(id) + ",\n")
|
||||
// cHeaderEvents.WriteString("#define Event" + eventTitle + " " + strconv.Itoa(id) + "\n")
|
||||
// if ignoreEvent {
|
||||
// continue
|
||||
// }
|
||||
// // Check if this is a window event
|
||||
// if strings.HasPrefix(event, "Window") {
|
||||
// windowDelegateEvents.WriteString(`- (void)` + delegateEventFunction + `:(NSNotification *)notification {
|
||||
// if( hasListeners(Event` + eventTitle + `) ) {
|
||||
// processWindowEvent(self.windowId, Event` + eventTitle + `);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//`)
|
||||
// }
|
||||
// // Check if this is a webview event
|
||||
// if strings.HasPrefix(event, "WebView") {
|
||||
// webViewFunction := strings.TrimPrefix(event, "WebView")
|
||||
// webViewFunction = string(bytes.ToLower([]byte{webViewFunction[0]})) + webViewFunction[1:]
|
||||
// webviewDelegateEvents.WriteString(`- (void)webView:(WKWebView *)webview ` + webViewFunction + `:(WKNavigation *)navigation {
|
||||
// if( hasListeners(Event` + eventTitle + `) ) {
|
||||
// processWindowEvent(self.windowId, Event` + eventTitle + `);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//`)
|
||||
// }
|
||||
// if strings.HasPrefix(event, "Application") {
|
||||
// applicationDelegateEvents.WriteString(`- (void)` + delegateEventFunction + `:(NSNotification *)notification {
|
||||
// if( hasListeners(Event` + eventTitle + `) ) {
|
||||
// processApplicationEvent(Event` + eventTitle + `);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//`)
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user