开发者

Intercepting A Dock Icon Click in OSX

开发者 https://www.devze.com 2023-04-11 15:01 出处:网络
I\'m looking for a 开发者_如何学编程way to intercept all dock icon clicks(so I can display various windows in my own way). Is there a way to do this?Check out [NSDockTilePlugin dockMenu] and see if ov

I'm looking for a 开发者_如何学编程way to intercept all dock icon clicks(so I can display various windows in my own way). Is there a way to do this?


Check out [NSDockTilePlugin dockMenu] and see if overriding that takes care of what you want to do.

http://developer.apple.com/library/mac/documentation/AppKit/Reference/NSDockTilePlugIn_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/NSDockTilePlugIn/dockMenu


This worked best for me.

Note that I just wanted to get notified of the dock icon clicked, I did not intend to customize the display of the window list - so it is solves a sligthly smaller problem than the OP had. But since search led me here, I think this answer will help others too.

Within applicationDidFinishLaunching:

  [[NSNotificationCenter defaultCenter] addObserver:self
     selector:@selector(applicationWillEnterForeground:)
         name:NSApplicationWillBecomeActiveNotification
       object:nil];

Then I get notified here:

- (void)applicationWillEnterForeground:(NSNotification *)application {
    // The dock icon was clicked, do your thing.
}

0

精彩评论

暂无评论...
验证码 换一张
取 消