• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSTableView - need something like tableView:shouldSelectRow:byExtendingSelection:?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: NSTableView - need something like tableView:shouldSelectRow:byExtendingSelection:?
      • From: Jim Correia <email@hidden>
References: 
 >NSTableView - need something like tableView:shouldSelectRow:byExtendingSelection:? (From: Jim Correia <email@hidden>)
 >Re: NSTableView - need something like tableView:shouldSelectRow:byExtendingSelection:? (From: Corbin Dunn <email@hidden>)
 >Re: NSTableView - need something like tableView:shouldSelectRow:byExtendingSelection:? (From: Jim Correia <email@hidden>)
 >Re: NSTableView - need something like tableView:shouldSelectRow:byExtendingSelection:? (From: Corbin Dunn <email@hidden>)
 >Re: NSTableView - need something like tableView:shouldSelectRow:byExtendingSelection:? (From: Jim Correia <email@hidden>)

  • Prev by Date: (no subject)
  • Next by Date: Re: (no subject)
  • Previous by thread: Re: NSTableView - need something like tableView:shouldSelectRow:byExtendingSelection:?
  • Next by thread: Re: NSTableView - need something like tableView:shouldSelectRow:byExtendingSelection:?
  • Index(es):
    • Date
    • Thread