On Mar 4, 2008, at 6:49 AM, Stéphane wrote:

On Mar 4, 2008, at 3:35 PM, Nick Rogers wrote:

Hi,
I have two NSTableView in my app (tableView1 and tableView2).
If I select a row in tableView1 and then if I select a row in tableView2, I want the row in tableView1 to be deselected. For this I'm using [tableView1 deselectAll: nil], but it leads to calling the delegate method again and leads to deselection of the selected row in tableView2 also.
So this way both table view's stands deselected.

Is there a noble way to do it?

I'm not sure it's noble since my blood is red but:

Listing:

- (void)tableViewSelectionDidChange:(NSNotification *)notification
{
        if ([[notification object] isEqual: tableView1] == YES)
        {
                

                if ([tableView1 numberOfSelectedRows]>0)
                {
                [tableView2 deselectAll:nil];

This will probably have the same problem; it will just stop after doing the callback twice.

Let me clarify what is happening. Public "user" action entry points, such as deselectAll: and selectAll:, need to inform the delegate that the selection changed. If you use -[table selectRowIndexes:[NSIndexSet indexSet] byExtendingSelection:NO] then you will avoid the notification/delegate being notified, since it is assumed you *know* what you are doing as the programmer.

-corbin_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to