Re: selectionShouldChangeInTableView called twice
Re: selectionShouldChangeInTableView called twice
- Subject: Re: selectionShouldChangeInTableView called twice
- From: Corbin Dunn <email@hidden>
- Date: Mon, 22 Dec 2008 09:12:27 -0800
On Dec 20, 2008, at 10:23 AM, Andre Masse wrote:
Hi,
I'm using a master/detail view in my application. If the user select
another row in the master table and the detail has been modified, I
want to present an alert to save, cancel or return to detail. I'm
not using binding here, only datasource and delegate methods. So in -
selectionShouldChangeInTableView: I return YES if the user saved or
cancelled and NO if he choose the third option.
Problem is that selectionShouldChangeInTableView is called twice
when returning NO. Having googled it, I found a couple of matches on
this list and no replies... To make sure this is a bug, I made a
test project available here and will radar it if it has no workaround:
http://idisk.mac.com/miyano/Public/TestRowChanges.zip
Now, since I can't rely on -selectionShouldChangeInTableView:, how
do you guys handle this?
Sorry for the late reply on this, but just to add what others have
said, and to make more sense of what is going on:
When the selection is changing, the tableview is in the middle of
tracking the mouse. It sends out the -
selectionShouldChangeInTableView: and expects an immediate answer.
Showing a non-modal dialog (ie: sheet) at this point can cause
problems that you wouldn't expect, specifically, the tableview needs
an answer so it can stop processing the mouse event.
So (as others have noted), the best solution is to always save off the
target selection, present your Save/Cancel UI (if "dirty"), and after
the UI has closed change the selection to the saved off target
selection. When your UI is present, you should return NO for
selectionShouldChange.
We do have a bug logged for this issue of the double-delegate calling,
but you are always welcome to log a new bug report with your test case.
thanks,
corbin
_______________________________________________
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