Activate existing windows for About/Preferences (fixes #72) (#73)

This commit is contained in:
Jakob Borg
2018-07-31 15:14:01 +02:00
committed by Jerry Jacobs
parent b074d55d49
commit a1af30c079
+18 -6
View File
@@ -214,6 +214,12 @@
// TODO: need a more generic approach for opening windows
- (IBAction)clickedPreferences:(NSMenuItem *)sender {
if (_preferencesWindow != nil) {
[NSApp activateIgnoringOtherApps:YES];
[_preferencesWindow.window makeKeyAndOrderFront:self];
return;
}
_preferencesWindow = [[STPreferencesWindowController alloc] init];
[_preferencesWindow showWindow:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
@@ -223,12 +229,18 @@
}
- (IBAction)clickedAbout:(NSMenuItem *)sender {
_aboutWindow = [[STAboutWindowController alloc] init];
[_aboutWindow showWindow:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(aboutWillClose:)
name:NSWindowWillCloseNotification
object:[_aboutWindow window]];
if (_aboutWindow != nil) {
[NSApp activateIgnoringOtherApps:YES];
[_aboutWindow.window makeKeyAndOrderFront:self];
return;
}
_aboutWindow = [[STAboutWindowController alloc] init];
[_aboutWindow showWindow:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(aboutWillClose:)
name:NSWindowWillCloseNotification
object:[_aboutWindow window]];
}
// TODO: need a more generic approach for closing windows