cocoabits / MASShortcut

Modern framework for managing global keyboard shortcuts compatible with Mac App Store. More details:
http://blog.shpakovski.com/2012/07/global-keyboard-shortcuts-in-cocoa.html
BSD 2-Clause "Simplified" License
1.52k stars 220 forks source link

NSPanel to move front issue #86

Closed YOnoda closed 8 years ago

YOnoda commented 8 years ago

It seems that when you register the shortcut and trigger the registered shortcut to open the app, the app opens but the NSPanel window does always show up on the front even if you already closed the panel, because the instance of the panel is still retained.

This does not occur when you manually select the app icon from the dock; it only occurs when launched via keyboard shortcut.

Is there any way to prevent the panel from being displayed when you trigger the shortcut? I use NSColorWell and NSColorPanel.

shpakovski commented 8 years ago

when you register the shortcut and trigger the registered shortcut to open the app

Could you please be more specific? Maybe show code that you use to open the app? MASShortcut is just a trigger which runs in the app using it, and it should not have any influence on other apps in the system.

YOnoda commented 8 years ago

Sorry, that was my problem. I wrote the code that brings my windows to the front when the app enters the foreground as follows:

    func applicationWillBecomeActive(notification: NSNotification) {
        let windows = NSApp.windows as [NSWindow]
        for window in windows {
            if window.className != NSColorPanel.className() {
                window.orderFront(self)
            }
        }
    } 

However, the similar code written in the shortcut handler didn't check on the NSColorPanel, making my app to bring the color panel to the front.

Sorry, the app was last updated more than 1 year ago and I should have checked it out more closely. I deeply apologize for the issue. So let me close the issue...