• 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: NSActionCell, mouse tracking and NSTableView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSActionCell, mouse tracking and NSTableView


  • Subject: Re: NSActionCell, mouse tracking and NSTableView
  • From: Ricky Sharp <email@hidden>
  • Date: Wed, 08 Dec 2004 14:54:16 -0600

On Wednesday, December 08, 2004, at 12:44PM, Mark Alldritt <email@hidden> wrote:

>I'm trying to create a NSActionCell subclass which implements roll-over
>effects for use within NSTableView and NSOutlineView.  I've tried
>implementing the following methods from NSCell, but they are not being
>invoked:
>
>- (void) mouseEntered:(NSEvent*) event
>- (void) mouseExited:(NSEvent*) event
>- (BOOL) startTrackingAt:(NSPoint) startPoint inView:(NSView*) controlView
>- (BOOL) continueTracking:(NSPoint) lastPoint at:(NSPoint) currentPoint
>inView:(NSView*) controlView
>- (void) stopTracking:(NSPoint) lastPoint at:(NSPoint) stopPoint
>inView:(NSView*) controlView mouseIsUp:(BOOL) flag

>How do I get these methoes to work (or otherwise get their functionality) in
>my NSCell subclass?

Please don't take the following as fact; I can only offer what I've currently observed.

I also have an NSActionCell subclass that serves as a custom button's cell (button is a subclass of NSControl).  Initially, I was planning to offer mouse-over effects, but I too could not figure out how to get things working at the cell level.  Mouse-over worked a-ok for my push buttons and switches (checkboxes), but not radio buttons (NSMatrix containing my custom cells).

I've since scrapped doing mouse-over support for many other reasons.

Something that you may want to do is to investigate subclassing NSTableView and NSOutlineView.  Perhaps you can add a tracking rectangle to the views themselves.  Then, in the revelent methods (e.g. mouseEntered) figure out which exact cell the mouse is over and have that cell do the right thing.

If in the future I ever plan to have cell-level mouse-over support, I think I'll investigate subclassing NSMatrix (or just come up with my own type of container) so that I'd have complete control over all mouse events.

I think what's going on in your case is that the view classes are processing their own events and ultimately not calling through to those in your custom cell.  Again, this is only a guess based upon what I've observed in the past.

Also note that mouseEntered: isn't a method of NSCell.  So it's probably safe to assume that the view system is currently designed such that only certain ones are aware that cells need this special behavior.

One such view is NSButton.  The NSButtonCell class does have a mouseEntered: method.  And, from failed experiments with subclasses of NSButton and NSButtonCell, there's definitely some hard-wired code in there that seems to only want to work with exact instances of NSButton/NSButtonCell rather than calling down to the subclass's implementation.

--
Rick Sharp
Instant Interactive(tm)

 _______________________________________________
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

References: 
 >NSActionCell, mouse tracking and NSTableView (From: Mark Alldritt <email@hidden>)

  • Prev by Date: reversing an NSString
  • Next by Date: Re: Drag and drop color swatches
  • Previous by thread: NSActionCell, mouse tracking and NSTableView
  • Next by thread: Re: NSActionCell, mouse tracking and NSTableView
  • Index(es):
    • Date
    • Thread