Re: Finder Sync extension menu limitations
Re: Finder Sync extension menu limitations
- Subject: Re: Finder Sync extension menu limitations
- From: Dragan Milić <email@hidden>
- Date: Fri, 10 Apr 2015 00:14:18 +0200
Hi Dave,
> On čet 09.04.2015., at 23.23, Dave Lyons wrote:
>
> Hi Dragan,
>
> You're exactly right about the limitations. The only other menu item property that's used is "enabled" (though typically you wouldn't want a disabled menu item here anyway).
>
> Because the presented NSMenu object lives in a different process from your code (in Finder.app, for example), it's impossible for your Finder Sync extension to get a reference to that menu. Some of the other limitations could be removed in the future, so filing a bug report with your priorities is always a good idea.
Thanks for confirming this, I supposed it had to do something with the fact of object living in different processes. Actually, all those properties I mentioned (+ “enabled”) are just used for menu item visueal appearance, but they’re also initialised to 0/nil/NULL. So, if in menu item’s action method, I try to access a sender’s title, it’s nil, even though the title is drawn on the screen. That applies to item’s “menu” property too, and it’s a bit strange and funny (until one realises the story about different processes) that the item is displayed in a menu, yet it’s “menu" property is nil :-)
I’ll definitely fill a bug report with some things I’d like to see improved or implemented. There aren’t many, I’d like a few more properties of menu items created in an extension to be reusable in items’ action methods:
- representedObject
- tag (although if the “representedObject” is enabled, tag can easily be worked around)
- indentation
- possibility to create hierarchical (sub)menus
The last one is, at the moment, the most important in my opinion, as it would enable creation of much more UI friendlier extensions and reduce contextual menu clutter. For the time being I created a work around this so whenever I’d like to have a hierarchical submenu, I create a single menu item, whose action shows a NSPopover attached to selected item(s) (similar to what Finder does for “Tags…” contextual menu item) and that popover contains NSPopUpButton with additional menu items. Of course, this required some playing around, registering a global event monitor (to record where in the screen a user clicked to invoke the menu and therefore to assume approximately where to “attach” the popover), creating opaque window to attach the popover to etc. But it’d be much better if all this is available out of the box.
Actually, reading this last paragraph, I realised another improvement of Finder Sync extension would be:
- possibility to get a NSPopover attached to selected/target URLs and provide our custom view controller to fill in its contents.
-- Dragan
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden