NSBrowser deselection problem
NSBrowser deselection problem
- Subject: NSBrowser deselection problem
- From: Greg Hulands <email@hidden>
- Date: Tue, 4 Dec 2007 11:32:53 -0800
Hi,
I am having a problem with deselecting a cell in an NSBrowser. In my
NSBrowserCell subclass I have implemented a fix recommended by Corbin
Dunn so that the browser:willDisplayCell:atRow:column: gets called
before drawing so the representedObject of the cell is set properly.
Here is the code for reference:
- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView
*)controlView {
if (![self isLoaded])
{
NSMatrix *matrix = (NSMatrix *)controlView;
NSBrowser *browser = [matrix browser];
int row = 0, col = [browser columnOfMatrix:matrix];
for (row = 0; row < [matrix numberOfRows]; row++)
{
NSCell *cell = [matrix cellAtRow:row column:0];
if (cell == self)
{
break;
}
}
[[browser delegate] browser:browser willDisplayCell:self atRow:row
column:col];
[self setLoaded:YES];
}
// do the drawing
}
What I am seeing at this stage is that when I deselect a cell using
the command key and clicking it, I see the cell deselect and then
reselect itself. When I release the mouse I get the target/action
method, but it contains the selected cell that really should have been
deselected.
If I comment out the if (![self isLoaded]) and let the cell call the
browser:willDisplayCell:atRow:column: delegate method everytime it is
about to draw itself, I can see that the when I perform the
deselection, that the browser:willDisplayCell:atRow:column: is called
twice - the first time the [browser selectedCells] is nil which is
correct, but then it calls it again, this time with the cell being
selected. When I release the mouse button I then get the target/action
method being invoked. The only place where I set a selection on the
browser is never being called during this sequence of events so I am
led to believe that this may be a bug in NSBrowser or the work around
for the NSBrowserCell subclass drawing problem isn't quite right.
Any information or pointers in the right direction are greatly
appreciated.
Thanks,
Greg
_______________________________________________
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