Re: NSBrower selectedCells lies
Re: NSBrower selectedCells lies
- Subject: Re: NSBrower selectedCells lies
- From: "Martin Redington" <email@hidden>
- Date: Fri, 23 May 2008 01:44:13 +0100
I've made some progress in hunting this down, although it seems a little weird.
Basically, in an NSBrowser, if you have a column with, for example,
three items, and you click on another,
- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
gets called a few times for each item, with the the selectedCells
values changing appropriately and correctly during the sequence and
calls.
In the case I'm running into, drawInteriorWithFrame only gets called
for some of the items, and only once, so the calls for the later, new
value of selectedCells are never made (hence "selectedCells lies").
*Something* seems to be stopping the later updates.
I have a test case that replicates this behaviour, with a fairly
minimal classes. Oddly, when I set the the browser's focusRingType to
NSFocusRingTypeNone, programmatically or in the nib, I get exactly the
same behaviour as in my test case. When I leave it set to the default,
I get the correct number and sequence of drawInteriorWithFrame: calls.
I'll file a bug for this later on.
Frustratingly, when I drop my app's browser classes into my minimal
test case, they seem to work ok. The only real difference left is in
my browser delegate methods - I wouldn't have expected them to break
this, but then I wouldn't have expected NSFocusRingTypeNone to either.
If anyone has any clues as to what might be going on here, that would
be great ...
On Wed, May 7, 2008 at 4:14 AM, Martin Redington
<email@hidden> wrote:
> more NSBrowser problems (on Leopard, building with Xcode 2.5 for Tiger+).
>
> My NSBrowser is set to allow multiple and branch selection. In my
> custom NSBrowserCell subclass, I over-ride -[NSBrowserCell
> drawInteriorWithFrame:inView:] to do some custom drawing when the cell
> is selected (I need to draw a bit of extra background, and also to
> make the font white).
>
> My over-ridden method looks more or less like this.
>
> - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
> {
> BOOL isSelected = [[(NSMatrix *)controlView selectedCells]
> containsObject:self];
>
> // if([self isHighlighted])
> if(isSelected)
> {
> // Do some custom stuff
> }
>
> [super drawInteriorWithFrame:myFrame inView:controlView];
> }
>
> What I'm finding is that if I select one NSBrowser cell, and then
> click on another cell to select it instead (*not* as well as), when
> drawInteriorWithFrame:inView is hit, both cells show up both in
> selectedCells, and isHighlighted, breaking my custom drawing.
>
> However, in this case, surely only one cell should be selected?
>
> Although my custom drawing is broken, the cells do highlight
> appropriately, so somewhere the "real" selection state is known.
>
> Where/how can I intercept the "real" selection state and do my drawing
> correctly?
>
> --
> http://www.mildmanneredindustries.com/
>
--
http://www.mildmanneredindustries.com/
_______________________________________________
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