mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 20:51:38 +08:00
[mac] Potential file dialog fix. Fix for starthidden. Partial WindowStartState
This commit is contained in:
parent
56ef4ddd47
commit
c678ab7d01
@ -14,6 +14,7 @@
|
||||
@interface AppDelegate : NSResponder <NSTouchBarProvider>
|
||||
|
||||
@property bool alwaysOnTop;
|
||||
@property bool startHidden;
|
||||
@property (retain) WailsWindow* mainWindow;
|
||||
|
||||
@end
|
||||
|
@ -16,16 +16,22 @@
|
||||
}
|
||||
- (void)applicationWillFinishLaunching:(NSNotification *)aNotification {
|
||||
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
||||
[self.mainWindow makeKeyAndOrderFront:self];
|
||||
if (self.alwaysOnTop) {
|
||||
[self.mainWindow setLevel:NSStatusWindowLevel];
|
||||
}
|
||||
if ( !self.startHidden ) {
|
||||
[self.mainWindow makeKeyAndOrderFront:self];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@synthesize touchBar;
|
||||
|
||||
@end
|
||||
|
@ -12,7 +12,12 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "WailsContext.h"
|
||||
|
||||
WailsContext* Create(const char* title, int width, int height, int frameless, int resizable, int fullscreen, int fullSizeContent, int hideTitleBar, int titlebarAppearsTransparent, int hideTitle, int useToolbar, int hideToolbarSeparator, int webviewIsTransparent, int alwaysOnTop, int hideWindowOnClose, const char *appearance, int windowIsTranslucent, int debug);
|
||||
#define WindowStartsNormal 0
|
||||
#define WindowStartsMaximised 1
|
||||
#define WindowStartsMinimised 2
|
||||
#define WindowStartsFullscreen 3
|
||||
|
||||
WailsContext* Create(const char* title, int width, int height, int frameless, int resizable, int fullscreen, int fullSizeContent, int hideTitleBar, int titlebarAppearsTransparent, int hideTitle, int useToolbar, int hideToolbarSeparator, int webviewIsTransparent, int alwaysOnTop, int hideWindowOnClose, const char *appearance, int windowIsTranslucent, int debug, int windowStartState, int startsHidden);
|
||||
void Run(void*);
|
||||
|
||||
void SetTitle(void* ctx, const char *title);
|
||||
|
@ -12,7 +12,7 @@
|
||||
#import "WailsMenu.h"
|
||||
#import "WailsMenuItem.h"
|
||||
|
||||
WailsContext* Create(const char* title, int width, int height, int frameless, int resizable, int fullscreen, int fullSizeContent, int hideTitleBar, int titlebarAppearsTransparent, int hideTitle, int useToolbar, int hideToolbarSeparator, int webviewIsTransparent, int alwaysOnTop, int hideWindowOnClose, const char *appearance, int windowIsTranslucent, int debug) {
|
||||
WailsContext* Create(const char* title, int width, int height, int frameless, int resizable, int fullscreen, int fullSizeContent, int hideTitleBar, int titlebarAppearsTransparent, int hideTitle, int useToolbar, int hideToolbarSeparator, int webviewIsTransparent, int alwaysOnTop, int hideWindowOnClose, const char *appearance, int windowIsTranslucent, int debug, int windowStartState, int startsHidden) {
|
||||
|
||||
[NSApplication sharedApplication];
|
||||
|
||||
@ -20,10 +20,27 @@ WailsContext* Create(const char* title, int width, int height, int frameless, in
|
||||
|
||||
result.debug = debug;
|
||||
|
||||
if ( windowStartState == WindowStartsFullscreen ) {
|
||||
fullscreen = 1;
|
||||
}
|
||||
|
||||
[result CreateWindow:width :height :frameless :resizable :fullscreen :fullSizeContent :hideTitleBar :titlebarAppearsTransparent :hideTitle :useToolbar :hideToolbarSeparator :webviewIsTransparent :hideWindowOnClose :safeInit(appearance) :windowIsTranslucent];
|
||||
[result SetTitle:safeInit(title)];
|
||||
[result Center];
|
||||
|
||||
switch( windowStartState ) {
|
||||
case WindowStartsMaximised:
|
||||
[result.mainWindow zoom:nil];
|
||||
break;
|
||||
case WindowStartsMinimised:
|
||||
//TODO: Can you start a mac app minimised?
|
||||
break;
|
||||
}
|
||||
|
||||
if ( startsHidden == 1 ) {
|
||||
result.startHidden = true;
|
||||
}
|
||||
|
||||
result.alwaysOnTop = alwaysOnTop;
|
||||
result.hideOnClose = hideWindowOnClose;
|
||||
|
||||
@ -306,6 +323,7 @@ void Run(void *inctx) {
|
||||
ctx.appdelegate = delegate;
|
||||
delegate.mainWindow = ctx.mainWindow;
|
||||
delegate.alwaysOnTop = ctx.alwaysOnTop;
|
||||
delegate.startHidden = ctx.startHidden;
|
||||
|
||||
[ctx loadRequest:@"wails://wails/"];
|
||||
[app setMainMenu:ctx.applicationMenu];
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
@property bool hideOnClose;
|
||||
@property bool shuttingDown;
|
||||
@property bool startHidden;
|
||||
|
||||
@property NSSize maxSize;
|
||||
@property NSSize minSize;
|
||||
|
@ -533,10 +533,10 @@
|
||||
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:arr options:0 error:nil];
|
||||
NSString *nsjson = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
||||
processOpenFileDialogResponse([nsjson UTF8String]);
|
||||
[nsjson release];
|
||||
[arr release];
|
||||
}];
|
||||
|
||||
ON_MAIN_THREAD([dialog runModal];)
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -579,11 +579,13 @@
|
||||
// Setup callback handler
|
||||
[dialog beginSheetModalForWindow:self.mainWindow completionHandler:^(NSModalResponse returnCode) {
|
||||
NSURL *url = [dialog URL];
|
||||
processSaveFileDialogResponse([url.path UTF8String]);
|
||||
if ( url != nil ) {
|
||||
processSaveFileDialogResponse([url.path UTF8String]);
|
||||
return;
|
||||
}
|
||||
processSaveFileDialogResponse("");
|
||||
}];
|
||||
|
||||
ON_MAIN_THREAD([dialog runModal];)
|
||||
|
||||
|
||||
}
|
||||
|
||||
- (void) SetAbout :(NSString*)title :(NSString*)description :(void*)imagedata :(int)datalen {
|
||||
|
@ -19,7 +19,7 @@
|
||||
}
|
||||
|
||||
- (NSMenuItem*) newMenuItemWithContext :(WailsContext*)ctx :(NSString*)title :(SEL)selector :(NSString*)key :(NSEventModifierFlags)flags {
|
||||
NSMenuItem *result = [[NSMenuItem new] autorelease];
|
||||
NSMenuItem *result = [NSMenuItem new];
|
||||
if ( title != nil ) {
|
||||
[result setTitle:title];
|
||||
}
|
||||
@ -45,7 +45,7 @@
|
||||
[super initWithTitle:title];
|
||||
}
|
||||
[self setAutoenablesItems:NO];
|
||||
return self;
|
||||
return [self init];
|
||||
}
|
||||
|
||||
- (void) appendSubmenu :(WailsMenu*)child {
|
||||
|
@ -47,6 +47,7 @@ func NewWindow(frontendOptions *options.App, debugMode bool) *Window {
|
||||
fullscreen := bool2Cint(frontendOptions.Fullscreen)
|
||||
alwaysOnTop := bool2Cint(frontendOptions.AlwaysOnTop)
|
||||
hideWindowOnClose := bool2Cint(frontendOptions.HideWindowOnClose)
|
||||
startsHidden := bool2Cint(frontendOptions.StartHidden)
|
||||
debug := bool2Cint(debugMode)
|
||||
|
||||
var fullSizeContent, hideTitleBar, hideTitle, useToolbar, webviewIsTransparent C.int
|
||||
@ -55,6 +56,7 @@ func NewWindow(frontendOptions *options.App, debugMode bool) *Window {
|
||||
|
||||
width := C.int(frontendOptions.Width)
|
||||
height := C.int(frontendOptions.Height)
|
||||
windowStartState := C.int(int(frontendOptions.WindowStartState))
|
||||
|
||||
title = c.String(frontendOptions.Title)
|
||||
|
||||
@ -75,7 +77,7 @@ func NewWindow(frontendOptions *options.App, debugMode bool) *Window {
|
||||
}
|
||||
var context *C.WailsContext = C.Create(title, width, height, frameless, resizable, fullscreen, fullSizeContent,
|
||||
hideTitleBar, titlebarAppearsTransparent, hideTitle, useToolbar, hideToolbarSeparator, webviewIsTransparent,
|
||||
alwaysOnTop, hideWindowOnClose, appearance, windowIsTranslucent, debug)
|
||||
alwaysOnTop, hideWindowOnClose, appearance, windowIsTranslucent, debug, windowStartState, startsHidden)
|
||||
|
||||
// Create menu
|
||||
result := &Window{
|
||||
|
Loading…
Reference in New Issue
Block a user