• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Contextual menus in view-based NSOutlineView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Contextual menus in view-based NSOutlineView


  • Subject: Re: Contextual menus in view-based NSOutlineView
  • From: Graham Cox <email@hidden>
  • Date: Thu, 12 Jun 2014 11:15:56 +1000

This could be a good solution, I'll give it a shot - thanks. Still a bit annoying that the "obvious" way should be broken for no very good reason that I can see.

--Graham




On 12 Jun 2014, at 11:09 am, Lee Ann Rucker <email@hidden> wrote:

> In my cell-based table I created an empty menu whose delegate was the outlineView, then implemented menuNeedsUpdate:, and it didn't need to change for view-based. I think it came from Apple sample code originally, and is basically
>
>  NSInteger clickedRow = [outlineView clickedRow];
>  if (clickedRow != -1) { // -1 means empty row
>      item = [outlineView itemAtRow:clickedRow];
>     [self updateMenu:menu forItem:item];
>  }
>
> and updateMenu:forItem: swaps out all of menu's contents for what that item needs. There's also another menu with the general outlineView contents, and if I need that one I do the same swap.
>
> On Jun 11, 2014, at 5:55 PM, Graham Cox wrote:
>
>> I'm having trouble getting contextual menus to work in a view-based NSOutlineView.
>>
>> I can set a menu on the whole outline view and that works, but I also need to have menus for each row. Setting a menu on the NSTableCellView subclass in IB doesn't work at all - it seems as if the menu isn't copied when the view is instantiated from the nib (the -menu property is nil on the view instance). But if I override -menu, or -menuForEvent: and return something, it is still not used. In fact those methods are never invoked. If I do the same on the NSTableRowView subclass, then the menu shows, but only if I click in areas that are not occupied by views within my cell view, which is not useful. If the table row gets the menu highlight, then the menu doesn't show (and the -menu method on the row isn't invoked).
>>
>> I did get this working in a cell-based outline view a few years ago, but with a view-based OV, I can't find the magic fairy dust I need. The simplest way would be just to set up the view's menu in IB, but it seems that's broken or overlooked in the OV implementation. Can anyone suggest a workaround other than those I've tried?
>>
>> --Graham
>>
>


_______________________________________________

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


References: 
 >Contextual menus in view-based NSOutlineView (From: Graham Cox <email@hidden>)
 >Re: Contextual menus in view-based NSOutlineView (From: Lee Ann Rucker <email@hidden>)

  • Prev by Date: Re: Contextual menus in view-based NSOutlineView
  • Next by Date: Re: Share and store RSA - public key in java server and vice versa
  • Previous by thread: Re: Contextual menus in view-based NSOutlineView
  • Next by thread: Re: Share and store RSA - public key in java server and vice versa
  • Index(es):
    • Date
    • Thread