mirror of
https://github.com/taigrr/wails.git
synced 2026-04-02 05:08:54 -07:00
Merge pull request #1007 from Ironpark/feature/on_before_close
[v2] feature / on-before-close resolve #978
This commit is contained in:
@@ -12,16 +12,15 @@
|
||||
#import "WailsContext.h"
|
||||
|
||||
@implementation WindowDelegate
|
||||
|
||||
- (BOOL)windowShouldClose:(WailsWindow *)sender {
|
||||
[sender orderOut:nil];
|
||||
if( self.hideOnClose == false ) {
|
||||
processMessage("Q");
|
||||
if( self.hideOnClose ) {
|
||||
[NSApp hide:nil];
|
||||
return false;
|
||||
}
|
||||
return !self.hideOnClose;
|
||||
processMessage("Q");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
- (void)windowDidExitFullScreen:(NSNotification *)notification {
|
||||
[self.ctx.mainWindow applyWindowConstraints];
|
||||
}
|
||||
|
||||
@@ -206,6 +206,9 @@ func (f *Frontend) WindowSetRGBA(col *options.RGBA) {
|
||||
}
|
||||
|
||||
func (f *Frontend) Quit() {
|
||||
if f.frontendOptions.OnBeforeClose != nil && f.frontendOptions.OnBeforeClose(f.ctx) {
|
||||
return
|
||||
}
|
||||
f.mainWindow.Quit()
|
||||
}
|
||||
|
||||
|
||||
@@ -208,6 +208,9 @@ func (f *Frontend) WindowSetRGBA(col *options.RGBA) {
|
||||
}
|
||||
|
||||
func (f *Frontend) Quit() {
|
||||
if f.frontendOptions.OnBeforeClose != nil && f.frontendOptions.OnBeforeClose(f.ctx) {
|
||||
return
|
||||
}
|
||||
f.mainWindow.Quit()
|
||||
}
|
||||
|
||||
|
||||
@@ -261,6 +261,9 @@ func (f *Frontend) WindowSetRGBA(col *options.RGBA) {
|
||||
}
|
||||
|
||||
func (f *Frontend) Quit() {
|
||||
if f.frontendOptions.OnBeforeClose != nil && f.frontendOptions.OnBeforeClose(f.ctx) {
|
||||
return
|
||||
}
|
||||
// Exit must be called on the Main-Thread. It calls PostQuitMessage which sends the WM_QUIT message to the thread's
|
||||
// message queue and our message queue runs on the Main-Thread.
|
||||
f.mainWindow.Invoke(winc.Exit)
|
||||
|
||||
@@ -45,9 +45,10 @@ type App struct {
|
||||
Menu *menu.Menu
|
||||
Logger logger.Logger `json:"-"`
|
||||
LogLevel logger.LogLevel
|
||||
OnStartup func(ctx context.Context) `json:"-"`
|
||||
OnDomReady func(ctx context.Context) `json:"-"`
|
||||
OnShutdown func(ctx context.Context) `json:"-"`
|
||||
OnStartup func(ctx context.Context) `json:"-"`
|
||||
OnDomReady func(ctx context.Context) `json:"-"`
|
||||
OnShutdown func(ctx context.Context) `json:"-"`
|
||||
OnBeforeClose func(ctx context.Context) (prevent bool) `json:"-"`
|
||||
Bind []interface{}
|
||||
WindowStartState WindowStartState
|
||||
|
||||
|
||||
Reference in New Issue
Block a user