OS X: sort out window visibility and focus.
This commit is contained in:
parent
dce906465d
commit
c25e4c8973
|
@ -400,7 +400,7 @@ CONVERT(Rect)
|
|||
.x = xy.x + size.width / 2,
|
||||
.y = xy.y - size.height / 2
|
||||
};
|
||||
[[self window] becomeKeyWindow];
|
||||
[[self window] makeKeyWindow];
|
||||
[super startEditing:text at:[self convertPointFromBacking:point]
|
||||
withHeight:fontHeight usingMonospace:FALSE];
|
||||
[self prepareEditorWithMinWidthInChars:minWidthChars];
|
||||
|
@ -1030,6 +1030,11 @@ void InitTextWindow() {
|
|||
[TW setBecomesKeyOnlyIfNeeded:YES];
|
||||
[GW addChildWindow:TW ordered:NSWindowAbove];
|
||||
|
||||
// Without this, graphics window is also hidden when the text window is shown
|
||||
// (and is its child window). We replicate the standard behavior manually, in
|
||||
// the application delegate;
|
||||
[TW setHidesOnDeactivate:NO];
|
||||
|
||||
NSScrollView *scrollView = [[NSScrollView alloc] init];
|
||||
[TW setContentView:scrollView];
|
||||
[scrollView setBackgroundColor:[NSColor blackColor]];
|
||||
|
@ -1047,9 +1052,9 @@ void InitTextWindow() {
|
|||
|
||||
void ShowTextWindow(bool visible) {
|
||||
if(visible)
|
||||
[TW orderFront:nil];
|
||||
[GW addChildWindow:TW ordered:NSWindowAbove];
|
||||
else
|
||||
[TW close];
|
||||
[TW orderOut:GW];
|
||||
}
|
||||
|
||||
void GetTextWindowSize(int *w, int *h) {
|
||||
|
@ -1140,6 +1145,8 @@ std::vector<std::string> SolveSpace::GetFontFiles() {
|
|||
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication;
|
||||
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender;
|
||||
- (void)applicationWillTerminate:(NSNotification *)aNotification;
|
||||
- (void)applicationWillBecomeActive:(NSNotification *)aNotification;
|
||||
- (void)applicationWillResignActive:(NSNotification *)aNotification;
|
||||
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename;
|
||||
- (IBAction)preferences:(id)sender;
|
||||
@end
|
||||
|
@ -1160,6 +1167,18 @@ std::vector<std::string> SolveSpace::GetFontFiles() {
|
|||
SolveSpace::SS.Exit();
|
||||
}
|
||||
|
||||
- (void)applicationWillBecomeActive:(NSNotification *)aNotification {
|
||||
if(SolveSpace::SS.GW.showTextWindow) {
|
||||
[GW addChildWindow:TW ordered:NSWindowAbove];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)applicationWillResignActive:(NSNotification *)aNotification {
|
||||
[TW setAnimationBehavior:NSWindowAnimationBehaviorNone];
|
||||
[TW orderOut:nil];
|
||||
[TW setAnimationBehavior:NSWindowAnimationBehaviorDefault];
|
||||
}
|
||||
|
||||
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename {
|
||||
return SolveSpace::SS.OpenFile([filename UTF8String]);
|
||||
}
|
||||
|
@ -1187,7 +1206,6 @@ int main(int argc, const char *argv[]) {
|
|||
SolveSpace::SS.Init();
|
||||
|
||||
[GW makeKeyAndOrderFront:nil];
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
[NSApp run];
|
||||
|
||||
SolveSpace::SK.Clear();
|
||||
|
|
Loading…
Reference in New Issue
Block a user