Re: Double-click action in an NSOutlineView
Re: Double-click action in an NSOutlineView
- Subject: Re: Double-click action in an NSOutlineView
- From: Jean-Francois Roy <email@hidden>
- Date: Tue, 14 Jan 2003 21:25:48 -0500
Thanks a lot, it works great. I was starting to get horrible ideas
about writing my own NSView subclass.
I have another question somewhat related to this. In the Finder, when
you single-click and stay over the NSCell for a small while, the cell
becomes editable. Now, I don't expect or desire to reproduce that
behavior exactly, however I would like to do something similar,
possibly switch to editing mode if the cell is clicked again after a
certain lapse of time greater than the double-click delay. Since the
action selector also fires even if you double-click (it fires just
before the double click selector fires), I am a bit concerned about
implementing that behavior.
Also, how do you switch to editing mode programatically, since -
(BOOL)outlineView:(NSOutlineView *)outlineView
shouldEditTableColumn:(NSTableColumn *)tableColumn item:(id)item won't
be called by a single click on the cell. Additionally, is there a
standard delay time for that behavior, or do I simply set it
arbitrarily to what I see fit?
I was also surprised that previously, the double click selector didn't
get called when I double-clicked on the custom cell, having turned off
it's editable flag. Only when I implemented -
(BOOL)outlineView:(NSOutlineView *)outlineView
shouldEditTableColumn:(NSTableColumn *)tableColumn item:(id)item did it
get called for double-clicks on the custom cell class. Perhaps Cocoa
assumes that if - (BOOL)outlineView:(NSOutlineView *)outlineView
shouldEditTableColumn:(NSTableColumn *)tableColumn item:(id)item isn't
implemented, it should always go in edit mode and so doesn't bother
about calling the double-click selector.
In any case, thanks.
On Tuesday, Jan 14, 2003, at 21:05 America/Montreal, Quentin Mathi
wrote:
Le mardi, 14 jan 2003, ` 23:53 Europe/Paris, Jean-Francois Roy a icrit
:
Hello.
I am new to Cocoa and I am trying to do the a file browser using a
NSOutlineView (not to browse the filesystem, but rather a compressed
archive).
I am using the ImageAndTextCell subclass Apple wrote in their
DragNDropOutlineView example (AppKit examples).
It works great, except that instead of editing the name when
double-clicking on a group item, I would like it to perform some
selector that would reload the content of the view so that the root
item is now the double-clicked group (like the Finder basically).
Then of course the question of how to provide editing capabilities to
group items begs itself.
I think you need to use the following delegate method :
outlineView:shouldEditTableColumn:item:
like that
- (BOOL)outlineView:(NSOutlineView *)outlineView
shouldEditTableColumn:(NSTableColumn *)tableColumn item:(id)item {
if ([outlineView isExpandable:item] && [[tableColumn identifier]
isEqual:@"theFirstTableColumn"]) {
return NO;
}
else {
return YES;
}
}
And you can use setDoubleAction: and setTarget to initialize you
outline view in order to handle the double-click
--
Quentin Mathi
email@hidden
Jeff Roy
--
Co-Founder of MacStorm
Programmer at MacStorm
http://www.macstorm.net
http://www.theworldcrafters.com
email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.