OS X: sort out window visibility and focus.
This commit is contained in:
parent
afafa5ec2e
commit
1dba594949
|
@ -402,7 +402,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];
|
||||
|
@ -1035,6 +1035,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]];
|
||||
|
@ -1052,9 +1057,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) {
|
||||
|
@ -1165,6 +1170,8 @@ const void *SolveSpace::LoadResource(const std::string &name, size_t *size) {
|
|||
- (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
|
||||
|
@ -1185,6 +1192,18 @@ const void *SolveSpace::LoadResource(const std::string &name, size_t *size) {
|
|||
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]);
|
||||
}
|
||||
|
@ -1212,7 +1231,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