Re: Contextual menu for NSTableCellView in NSOutlineView
Re: Contextual menu for NSTableCellView in NSOutlineView
- Subject: Re: Contextual menu for NSTableCellView in NSOutlineView
- From: Konidaris Christos <email@hidden>
- Date: Thu, 11 Feb 2016 00:26:45 +0200
Thanks for the insight Ken. I’ll try setting the menu manually tomorrow (it’s half past midnight here) and let you know. But shouldn’t the -menuForEvent:(NSEvent *)event for my NSTableCellView subclass work instead ?
- Christos
> On 11 Feb 2016, at 00:18, Ken Thomases <email@hidden> wrote:
>
> Any connection you make from a table cell view to something outside of the table column is suspect. It probably doesn't work.
>
> The views "inside" of a table column are actually in a sub-NIB. There's a NIB archived to a data blob that's embedded in the NIB holding the outline view. That NIB is unarchived and loaded by the table/outline view in its -makeViewWithIdentifier:owner: method. The owner is whatever you pass to that method. (If you let the table/outline view create views without its delegate being involved, it will pass its own delegate as the owner.)
>
> When that sub-NIB is loaded, it contains just its own objects. None of the other objects from the outer NIB. The menu is presumably in the outer NIB, not the sub-NIB. So, the cell views won't be able to establish their connection to the menu.
>
> One exception is the File's Owner placeholder. A connection to that works, but may give a different result than you expect. The File's Owner for the sub-NIB is the owner passed to -makeViewWithIdentifier:owner:. It's not the owner of the outer NIB.
>
> You will need to connect the menu programmatically, most likely in your delegate's -outlineView:viewForTableColumn:item: method.
>
> Regards,
> Ken
>
>> On Feb 10, 2016, at 3:54 PM, Konidaris Christos <email@hidden> wrote:
>>
>> Yes I did set it, to the outlineView’s delegate object.
>>
>>
>>> On 10 Feb 2016, at 23:32, Lee Ann Rucker <email@hidden> wrote:
>>>
>>> Did you set the menu's delegate? It doesn't know about the outlineView's delegate.
>>>
>>>> On Feb 10, 2016, at 9:10 AM, Konidaris Christos <email@hidden> wrote:
>>>>
>>>> I cannot get contextual menus to work inside the cells of my view-based NSOutlineView.
>>>>
>>>> In my cell view I have one standard NSImageView and one NSTextFieldCell. I set the menu for the outline view in IB. When I (right) click on a cell outside the two views the contextual menu appears. When I click on one of the two fields it does not. I can see from the logs that the menu delegate's menuNeedsUpdate: is not called in this case. I tried setting the same menu as the menu for these views in IB with the same result. I get the same behavior when I implement -menuForEvent:(NSEvent *)event for my NSOutlineView subclass instead of setting the menu in IB.
>>>>
>>>> I also tried implementing -menuForEvent:(NSEvent *)event for my NSTableCellView subclass with no better luck. This all in Xcode 7.2.1, deployment target set to 10.9, no ARC.
>>>>
>>>> Does anybody know what I am missing for the contextual menu to work for my cell views?
>>>>
>>>> Thanks in advance,
>>>>
>>>> - Christos Konidaris
>>>>
>>>
>>
>>
>> _______________________________________________
>>
>> 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
>
_______________________________________________
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