• 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: Another NSOutlineView question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Another NSOutlineView question


  • Subject: Re: Another NSOutlineView question
  • From: Graham Cox <email@hidden>
  • Date: Wed, 10 Dec 2008 10:36:58 +1100


On 10 Dec 2008, at 3:34 am, Corbin Dunn wrote:

Le Dec 9, 2008 à 12:40 AM, Volker in Lists a écrit :

Hi,

you should be able to detect a double click and call a method then that either temporarily allows the selection or directly starts the edit mode. I do have a similar setup - don't do editing, but I use the double click action via bindings to attach notes to such an unselectable item.


This approach may work, but it will give some undesired UI; this app would the only be editable on double clicking, while other apps edit on single-click (ala Leopard NSTableView and Finder).


You want to use this delegate method:

/* Optional - Custom tracking support
It is possible to control the ability to track a cell or not. Normally, only selectable or selected cells can be tracked. If you implement this method, cells which are not selectable or selected can be tracked, and vice-versa. For instance, this allows you to have an NSButtonCell in a table which does not change the selection, but can still be clicked on and tracked.
*/
- (BOOL)tableView:(NSTableView *)tableView shouldTrackCell:(NSCell *)cell forTableColumn:(NSTableColumn *)tableColumn row: (NSInteger)row AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;



Return YES for your cell, and it should be trackable, and hence editable...


corbin



Hth,
volker

Am 09.12.2008 um 06:55 schrieb Graham Cox:

In my NSOutlineView, I disallow selection of group items by implementing the delegate method -outlineView:shouldSelectItem:, which works fine, but I still want to be able to edit the titles of group items. The above method prevents this also.

How can I prevent selection of the the item but still allow editing of its title string?


tia,



OK, I added that method (in its outlineView version) to my delegate and I'm simply returning YES always. I have verified that the method is being called when I click on the view.

Unfortunately, it's not doing anything useful for me - it always changes the selection to the row I click before flipping checkbox states for example, and I am still unable to edit the name of a group item (which is being prevented from being selected as desired by the - outlineView:shouldSelectItem: delegate method).

Any idea why this wouldn't work as advertised? These are the only two delegate methods I'm implementing other than watching for selection changes and item expansion notifications.


Code:

- (BOOL) outlineView:(NSOutlineView*) outlineView shouldSelectItem: (id) item
{
#pragma unused(outlineView)

return [item layerMayBecomeActive];
}



- (BOOL) outlineView:(NSOutlineView*) oView shouldTrackCell: (NSCell*) cell forTableColumn:(NSTableColumn*) tableColumn item:(id) item
{
#pragma unused(oView,cell,tableColumn,item)

NSLog(@"will track cell: %@", cell ); // this does log on each click

return YES;
}




Another question - is there a way to prevent the outline view from making itself first responder when clicked unless absolutely necessary, but without subclassing to override -acceptsFirstResponder?

thanks,

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


  • Follow-Ups:
    • Re: Another NSOutlineView question
      • From: Corbin Dunn <email@hidden>
References: 
 >Another NSOutlineView question (From: Graham Cox <email@hidden>)
 >Re: Another NSOutlineView question (From: Volker in Lists <email@hidden>)
 >Re: Another NSOutlineView question (From: Corbin Dunn <email@hidden>)

  • Prev by Date: Re: How Can I Notify DrawRect Method?
  • Next by Date: problems debugging cocoa app w/ gdb
  • Previous by thread: Re: Another NSOutlineView question
  • Next by thread: Re: Another NSOutlineView question
  • Index(es):
    • Date
    • Thread