Re: NSTableView - need something like tableView:shouldSelectRow:byExtendingSelection:?
Re: NSTableView - need something like tableView:shouldSelectRow:byExtendingSelection:?
- Subject: Re: NSTableView - need something like tableView:shouldSelectRow:byExtendingSelection:?
- From: Corbin Dunn <email@hidden>
- Date: Thu, 2 Jun 2005 14:50:17 -0700
Is there any way to avoid this?
okay, the simple answer is that we really need to add support for this.
the "work around" answer is to change your delegate method to below.
Some comments: selectRowIndexes is called when the selection is to
really change. shouldSelectRow is lacking "byExtendingSelection", as
we already determined. To work around this, you can determine if a
drag is happening and the right thing should happen.
---corbin
@implementation MyAppDelegate
- (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(int)row
byExtendingSelection: (BOOL)extend
{
//.... existing code that was here is required to handle shift/cmd
clicks, and is pretty much copied below
}
- (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(int)row {
BOOL shouldSelect = YES;
// the mouse will be dragging when we are extending the selection
BOOL selecting = [[NSApp currentEvent] type] == NSLeftMouseDragged;
if (selecting) {
// If we are extending the selection, disallow if the
proposed row is
// the first row, or the last row
if ((row == 0) || (row == [tableView numberOfRows] - 1))
{
shouldSelect = NO;
}
// Disallow if the first or the last row are already selected
if (shouldSelect)
{
if (([tableView isRowSelected: 0]) ||
([tableView isRowSelected: [tableView numberOfRows]
- 1]))
{
shouldSelect = NO;
}
}
}
NSLog(@"shouldSelect %d: is %d", row, shouldSelect);
return shouldSelect;
}
@end
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden