How to display an NSOpenPanel from a dock menu

74 Views Asked by At

I would like to have a menu item in my application dock menu that displays an NSOpenPanel modal dialog, with the following requirements:

  • The menu item should work regardless of whether my application is active or inactive.
  • The menu item should work regardless of whether my application has open windows or no open windows.
  • The NSOpenPanel should display on top of all application windows, even windows of other applications, and should accept keyboard input.
  • The dock icon for my application should not bounce.
  • No windows of my application should be brought forward.

I have yet to find a way to do this. I have tried the following APIs, but all have the potential to violate one or more of the above requirements.

  • NSRunningApplication activateWithOptions:
  • NSApplication activateIgnoringOtherApps:
  • makeKeyAndOrderFront: on the NSOpenPanel
  • orderFront: on the NSOpenPanel
  • orderFrontRegardless: on the NSOpenPanel

I did a quick survey of other applications and did not find any with a dock menu item that creates a modal dialog, so I have no proof that it is possible to do what I want.

Supporting the dock menu item when my application is not running is not a requirement.

0

There are 0 best solutions below