• 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: How to implement NSBrowser -shouldSelectCell:?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to implement NSBrowser -shouldSelectCell:?


  • Subject: Re: How to implement NSBrowser -shouldSelectCell:?
  • From: Nick Zitzmann <email@hidden>
  • Date: Mon, 21 Jun 2004 08:56:12 -0600

On Jun 21, 2004, at 6:29 AM, Bill Cheeseman wrote:

I now find myself in need of an NSBrowser analog of NSTableView's
-shouldSelectRow: delegate method. I'll call it -shouldSelectCell: or
-shouldSelectPath:. I need to prevent the user from selecting specific cells
(that is, specific paths), leaving the previous selection in effect without
flashing selection highlighting. I don't mind subclassing NSBrowser, if that
is what's required.

Any hints on how to do this?

Actually, in order to do this, you need to subclass NSMatrix and do this:

1. Use NSBrowser's -setMatrixClass: method to use the NSMatrix subclass.
2. In the NSMatrix, get a pointer to the NSBrowser. You can either browse the superview hierarchy for the first class of type "NSBrowser", or if you're using an active delegate, have the browser send a pointer to the matrix when -browser:createRowsForColumn:inMatrix: is called in your delegate.
3. Override -mouseDown: in the matrix and call -getRow:column:forPoint: to figure out where the user clicked. Then you can send a -browser:shouldSelectInRow:column: (or whatever) message to the NSBrowser's delegate. You probably know what to do from there...

Note that, if you want to select something in the matrix class, then you should call NSBrowser's selection methods from the matrix subclass. I don't know if this is still true in Mac OS X 10.3.x, but I noticed that in 10.2.x the browser keeps its selection state separate from the state of each matrix. I don't know why.

Nick Zitzmann
<http://www.chronosnet.com/>
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: How to implement NSBrowser -shouldSelectCell:?
      • From: Nick Zitzmann <email@hidden>
References: 
 >How to implement NSBrowser -shouldSelectCell:? (From: Bill Cheeseman <email@hidden>)

  • Prev by Date: Re: Computed Columns in NSTableView
  • Next by Date: Re: How to implement NSBrowser -shouldSelectCell:?
  • Previous by thread: How to implement NSBrowser -shouldSelectCell:?
  • Next by thread: Re: How to implement NSBrowser -shouldSelectCell:?
  • Index(es):
    • Date
    • Thread