Re: Problem with NSOutlineView outlineView:willDisplayCell:forTableColumn:item: delegate method
Re: Problem with NSOutlineView outlineView:willDisplayCell:forTableColumn:item: delegate method
- Subject: Re: Problem with NSOutlineView outlineView:willDisplayCell:forTableColumn:item: delegate method
- From: Tim Hewett <email@hidden>
- Date: Thu, 27 May 2004 17:13:06 +0100
(to Bill) I appreciate your help, thanks.
I've since added some debug to the cell's drawWithFrame:inView: method
and it shows interesting behaviour in both my app and also (importantly)
it shows the developer CD example "DragNDropOutlineView" behaves
identically. What actually happens is slightly different to what I
described
previously - the problem only occurs when you change row by clicking on
the part of the new row which is within the column containing the
custom cell.
If you click elsewhere on the row to be selected, it all works fine.
This is
also the case with my own application now that another column has
been added to test this (it normally has only one), i.e. if you select
a part
of a new row which is outside of the custom cell column bounds, the
checkbox flickering (i.e. the original problem being described) does not
happen.
This is what appears when row 3 is clicked on in DragNDropOutlineView,
debug text added by me. The "currentRow" value is that held in a new
global int, set by willDisplayCell: when it is called to update the
cell for
an item, read by the cell's drawWithFrame: method to help tie the frame
origin Y coordinate to the row number the cell is currently containing
values for. You'll see further down how this relationship breaks down
to cause the symptoms I've been describing.
DEBUG: App/Controller willDisplayCell for row 3 column 0
DEBUG: ImageAndTextCell setImage : 0x350040
DEBUG: ImageAndTextCell drawWithFrame at cellFrame.origin.y 55.000000,
currentRow is 3, text is EAGLE
Great, no problem, so row 3 is located at Y coordinate 55.0. Now I click
on row 5:
DEBUG: App/Controller willDisplayCell for row 3 column 1
DEBUG: App/Controller willDisplayCell for row 3 column 2
DEBUG: App/Controller willDisplayCell for row 4 column 0
DEBUG: ImageAndTextCell setImage : 0x3501b0
DEBUG: ImageAndTextCell drawWithFrame at cellFrame.origin.y 73.000000,
currentRow is 4, text is BOILER
DEBUG: App/Controller willDisplayCell for row 4 column 1
DEBUG: App/Controller willDisplayCell for row 4 column 2
DEBUG: ImageAndTextCell drawWithFrame at cellFrame.origin.y 91.000000,
currentRow is 4, text is TARHEEL <<<<<<<<<<<<<<<<<<< foo
DEBUG: App/Controller willDisplayCell for row 5 column 1
DEBUG: App/Controller willDisplayCell for row 5 column 2
DEBUG: App/Controller willDisplayCell for row 5 column 0
DEBUG: ImageAndTextCell setImage : 0x350330
DEBUG: ImageAndTextCell drawWithFrame at cellFrame.origin.y 91.000000,
currentRow is 5, text is TARHEEL <<<<<<<<<<<<<<<<<<< bar
So row 3 is located at origin Y position 55.0, row 4 at 73.0, and row 5
at 91.0.
You can see where it goes wrong. At the line marked "foo" the cell
contains
data for row 4, since that is the last data put in it as shown by when
the
setImage method was last called on the cell. But, the Y coordinate has
changed
to that for row 5, and then the cell's drawWithFrame method is called.
So row 4's
image is temporarily drawn at row 5's coordinates. Then... finally
willDisplayCell
gets to update the cell's image for row 5, and the proper image is now
displayed
at row 5, at the line marked "bar".
So row 5 gets displayed twice, once with row 4's cell, then with row
5's cell.
The same happens with my own application, the consequence being that if
the
cell above has the checkbox "on" and the selected cell doesn't (or vice
versa),
the selected cell's checkbox flickers between what it shouldn't show,
then
what it should.
My own "ButtonAndTextCell" was very much based on DragNDropOutlineView's
ImageAndTextCell so perhaps both are bugged, but frankly right now I
don't
believe that. I think this is an outline view problem - it seems to me
that the debug
logs above show this pretty clearly. The outline view is simply
displaying the cell
contents in the wrong row without telling the delegate that it will do
that, contrary
to the definition of the "willDisplayCell:" delegate interface.
Regards,
Tim.
http://www.coolatoola.com
On 27 May 2004, at 12:36, email@hidden wrote:
However if the outline view indicates it will display a cell for a row
and
column, and you setup the cell for that row and column, you would
expect the view then to display the cell in _that_ row and column when
you return from the delegate. Normally for me this works fine, but in
the scenario described where you click from a higher row to a lower
one, it doesn't, it all goes wrong like this:
Sorry, then, I can't help. My most completely debugged outline view
doesn't
exhibit this problem, although it includes a checkbox in one of its
columns.
I guess this suggests that the problem you're experiencing is probably
in
your code, not Apple's.
I will say that it took me a surprisingly long time to get my outline
view
working properly. Correct usage of NSOutlineView is an unusually
complex
subject.
_______________________________________________
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.