Re: NSTextFieldCell and trackMouse
Re: NSTextFieldCell and trackMouse
- Subject: Re: NSTextFieldCell and trackMouse
- From: Alastair Houghton <email@hidden>
- Date: Mon, 6 Aug 2007 14:14:44 +0100
On 6 Aug 2007, at 13:29, Seth Pellegrino wrote:
On Aug 6, 2007, at 6:42 AM, I. Savant wrote:
On Aug 6, 2007, at 12:00 AM, Seth Pellegrino wrote:
I have a custom NSTextFieldCell subclass, and in that subclass I
override -trackMouse:inRect:ofView:untilMouseUp because I want to
capture mouse events (specifically mouse down events). However, -
trackMouse never gets called.
So ... why not override -mouseDown: instead of -trackMouse...?
Unfortunately, NSCell is not a descendant of NSResponder, so it has
no -mouseDown: to override. According to stated in this thread: <
http://lists.apple.com/archives/cocoa-dev/2006/Jul/msg00198.html >
and CocoaDev < http://www.cocoadev.com/index.pl?
WrappingTwoNSCellsIntoOne > the 'proper' way to track mouse events
from within an NSCell is to use -trackMouse. The code included in
my original email works perfectly if it is part of an NSButtonCell
or NSSliderCell, but I can't get it to respond properly when part
of an NSTextFieldCell. I'm especially confused because, according
to the two sourced I quoted above, others have overriden -
trackMouse and had it just work.
Sometimes mouse tracking is done by the view rather than the cell,
for one reason or another. You might need to implement -mouseDown:
on the view to call -trackMouse:inRect:ofView:untilMouseUp in order
to get things going. Also, text fields are a bit of an odd case in
that, when you're editing them, you're actually interacting with the
field editor rather than the text field itself. So check that you
aren't expecting to get clicks that would be swallowed by the field
editor... if you are, then you might need a custom field editor.
Finally, check that you don't have a typo in the method name. That's
a common reason for methods not firing when you expect them to.
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
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