• 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: NSButtonCell doesn't visually update during trackMouse:inRect:ofView:untilMouseUp:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSButtonCell doesn't visually update during trackMouse:inRect:ofView:untilMouseUp:


  • Subject: Re: NSButtonCell doesn't visually update during trackMouse:inRect:ofView:untilMouseUp:
  • From: Ben Lachman <email@hidden>
  • Date: Mon, 17 Mar 2008 23:09:06 -0400

So my view is a NSControl subclass and after playing with this some it seems you have to do one more thing. If you're going to have a control handle multiple cells (in my case button cells) you have to call setCell: for the correct cell in mouseDown: and then let super handle the mouse event. This seems to work much better than trying to handle the event yourself.

Does this sound right to you Ken?

In any case I think there should really be more info on how to subclass NSControl and NSCell. The developer docs are really sparse on this. I filed a bug asking for a guide on this topic (rdar:// 5804311).

->Ben
--
Ben Lachman
Acacia Tree Software

http://acaciatreesoftware.com

email@hidden
740.590.0009

On Mar 17, 2008, at 4:25 PM, Ken Ferry wrote:

On Mon, Mar 17, 2008 at 8:49 AM, glenn andreas <email@hidden> wrote:

On Mar 17, 2008, at 1:42 AM, Ben Lachman wrote:

I have a few NSButtonCells that I'm using in a custom view.  I need
them to track the mouse during clicks and do this by calling
NSCell's trackMouse:inRect:ofView:untilMouseUp:.  This works fine
except that the button cells never update their graphical state by
highlighting or whatever.  However if I call performClick: on them
the button updates as it should.  Is the only solution to this to
implement mouse tracking at the view instead of at the cell level?


 You need to set the control view of the cell to your view and then
 implement the appropriate [update|draw]cell[inside]: methods in your
 view.

Or, a bit more specifically, setControlView: will fail to store anything if the passed view is not an NSControl. You can use an NSCell to purely stamp out drawing in an NSView, but more complicated interaction requires the view to be an NSControl, so that the cell can message the control in various ways. It isn't just updateCell:.

Ken Ferry
Cocoa Frameworks

Basically a cell expects to be inside a control and needs to be
able to tell that control to draw itself (and thus redraw the cell).
One would think that the parameters to trackMouse would be sufficient
to have the cell handle this by itself, but since a control could have
a background behind the cell, it's really up to the control to decide
how to redraw the cell.


_______________________________________________

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


References: 
 >NSButtonCell doesn't visually update during trackMouse:inRect:ofView:untilMouseUp: (From: Ben Lachman <email@hidden>)
 >Re: NSButtonCell doesn't visually update during trackMouse:inRect:ofView:untilMouseUp: (From: glenn andreas <email@hidden>)
 >Re: NSButtonCell doesn't visually update during trackMouse:inRect:ofView:untilMouseUp: (From: "Ken Ferry" <email@hidden>)

  • Prev by Date: Re: interface builder 3 question
  • Next by Date: Re: Modifying glyph storage in NSLayoutManager
  • Previous by thread: Re: NSButtonCell doesn't visually update during trackMouse:inRect:ofView:untilMouseUp:
  • Next by thread: Prevent application activation after dragging items to the Dock icon?
  • Index(es):
    • Date
    • Thread