Re: How to require contiguous selection in a table view?
Re: How to require contiguous selection in a table view?
- Subject: Re: How to require contiguous selection in a table view?
- From: Matt Neuburg <email@hidden>
- Date: Thu, 16 Aug 2007 09:14:57 -0700
- Thread-topic: How to require contiguous selection in a table view?
On Mon, 6 Aug 2007 19:53:31 +0200, Arthur C. <email@hidden> said:
>I want to have my table view allowing multiple selections, but only if the
selection is contiguous.
>This is needed because I want to have drag and drop operations inside the table
view to reorder some properties.
>I think there should be a simple boolean 'setRequiresContiguousSelection' or
something next to the 'allowsMultipleSelection'.
>
>What I'm doing now is a bit more complicated. I'm using a custom array
controller that I need for other purposes.
>I listen to the NSTableViewSelectionDidChangeNotification, and then I check in
the array controller which indexes are selected (it returns an NSIndexSet).
>If it is discontiguous, I want to change the selection so that only the row
that was last clicked (tried to add to the selection or tried to deselect) gets
selected.
>
>The question is how to do this - the 'selectedRow' operation from NSTableView
gives only the row that was last added to the selection; the 'clickedRow'
operation that I want does not seem to work; it returns -1. So, how should this
be done?
The trouble is that you don't get an event soon enough from the table view.
What you'd like is to be told that the user is trying to alter the
selection, so you can give a thumbs up or thumbs down to what the user is
trying to do. Instead, you receive a notification only after it is too late
to prevent the user from making the selection.
We have already discussed this issue, for example in this thread:
<http://www.cocoabuilder.com/archive/message/cocoa/2004/8/17/114763>
What I do is to memorize the current selection every time it changes. Then,
when the user changes the selection again, if he's done something I
disapprove of, I force the selection back to the way it was. This is
annoying to the user but it's the best you can do given the lack of property
notifications from the table view. m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
_______________________________________________
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