• 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: NSTableView and programmatic changing of contextual menu
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTableView and programmatic changing of contextual menu


  • Subject: Re: NSTableView and programmatic changing of contextual menu
  • From: Corbin Dunn <email@hidden>
  • Date: Tue, 25 Aug 2009 09:11:25 -0700


On Aug 25, 2009, at 8:58 AM, Kyle Sluder wrote:

On Tue, Aug 25, 2009 at 8:35 AM, Jason Foreman<email@hidden> wrote:
Another way is to implement the
-tableView:willDisplayCell:forTableColumn:row: delegate method and assign
the cell's menu there.

Table views reuse their cells. You can't do a per-row menu by setting the cell menu, because there's only one cell for a column.

That is true; table views reuse cells.

However, it will work (and it is a recommended way to solve this problem), since the tableView will first acquire a "preparedCellAtColumn:row:", which calls tableView:willDisplayCell:. So, any menu you have set there will correctly is used. This technique is also shown in the DragNDropOutlineView demo app on 10.5.


- (void)outlineView:(NSOutlineView *)outlineView willDisplayCell: (NSCell *)cell forTableColumn:(NSTableColumn *)tableColumn item:(id) item {
SimpleNodeData *nodeData = [item representedObject];
...
} else if ([[tableColumn identifier] isEqualToString:COLUMNID_IS_EXPANDABLE]) {
[cell setEnabled:nodeData.container];
// On Mac OS 10.5 and later, in willDisplayCell: we can dynamically set the contextual menu (right click menu) for a particular cell. If nothing is set, then the contextual menu for the NSOutlineView itself will be used. We will set a different menu for the "Expandable?" column, and leave the default one for everything else.
[cell setMenu:expandableColumnMenu];
}
// For all the other columns, we don't do anything.
}


corbin


_______________________________________________

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


  • Follow-Ups:
    • Re: NSTableView and programmatic changing of contextual menu
      • From: Kyle Sluder <email@hidden>
References: 
 >NSTableView and programmatic changing of contextual menu (From: Jack Carbaugh <email@hidden>)
 >Re: NSTableView and programmatic changing of contextual menu (From: Kyle Sluder <email@hidden>)
 >Re: NSTableView and programmatic changing of contextual menu (From: Jack Carbaugh <email@hidden>)
 >Re: NSTableView and programmatic changing of contextual menu (From: Kyle Sluder <email@hidden>)
 >Re: NSTableView and programmatic changing of contextual menu (From: Jason Foreman <email@hidden>)
 >Re: NSTableView and programmatic changing of contextual menu (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: applicationWillTerminate: issue
  • Next by Date: Re: NSTableView and programmatic changing of contextual menu
  • Previous by thread: Re: NSTableView and programmatic changing of contextual menu
  • Next by thread: Re: NSTableView and programmatic changing of contextual menu
  • Index(es):
    • Date
    • Thread