Re: Custom tracking in a NSTextFieldCell
Re: Custom tracking in a NSTextFieldCell
- Subject: Re: Custom tracking in a NSTextFieldCell
- From: Eric Gorr <email@hidden>
- Date: Thu, 8 Jan 2009 16:19:19 -0500
Well, I was finally able to spot the delegate method:
-outlineView:shouldTrackCell:forTableColumn:item:
and simply return YES.
This caused trackMouse & startTrackingAt to be called, but this isn't
useful until stopTracking is called. For some reason, it isn't.
I would be interested in learning why this might not be the case and
what I can do about it.
Thank you.
On Jan 8, 2009, at 10:46 AM, Eric Gorr wrote:
If it matters, this is within a NSOutlineView.
In the "Control and Cell Programming Topics for Cocoa" guide, it
does state:
Controls manage the behavior of their cells. By inheritance from
NSView, controls derive the ability for responding to user actions
and rendering their on-screen representation. When users click on a
control, it responds in part by sending
trackMouse:inRect:ofView:untilMouseUp: to the cell that was clicked.
and
If you want to implement your own mouse-tracking or mouse-up
behavior, consider overriding
startTrackingAt:inView:, continueTracking:at:inView:, and
stopTracking:at:inView:mouseIsUp:.
But, I am not seeing any of this documented behavior take place.
My own implementation currently looks like:
- (BOOL)trackMouse:(NSEvent *)theEvent inRect:(NSRect)cellFrame
ofView:(NSView *)controlView untilMouseUp:(BOOL)untilMouseUp
{
NSLog( @"trackMouse" );
return [super trackMouse:theEvent inRect:cellFrame
ofView:controlView untilMouseUp:untilMouseUp];
}
- (BOOL)startTrackingAt:(NSPoint)startPoint inView:(NSView
*)controlView
{
NSLog( @"startTrackingAt" );
return [super startTrackingAt:startPoint inView:controlView];
}
- (void)stopTracking:(NSPoint)lastPoint at:(NSPoint)stopPoint inView:
(NSView *)controlView mouseIsUp:(BOOL)flag
{
NSLog( @"stopTracking" );
[super stopTracking:lastPoint at:stopPoint inView:controlView
mouseIsUp:flag];
}
and I never see any of the log messages and any breakpoints set
never get hit.
On Jan 7, 2009, at 6:26 PM, Eric Gorr wrote:
I need to do some custom mouse tracking in a NSTextFieldCell.
Based on the documentation, when a cell is clicked,
- (BOOL)startTrackingAt:(NSPoint)startPoint inView:(NSView
*)controlView
should be called.
However, neither this method nor
- (void)stopTracking:(NSPoint)lastPoint at:(NSPoint)stopPoint
inView:(NSView *)controlView mouseIsUp:(BOOL)flag
- (BOOL)trackMouse:(NSEvent *)theEvent inRect:(NSRect)cellFrame
ofView:(NSView *)controlViewuntilMouseUp:(BOOL)untilMouseUp
are ever invoked. I cannot seem to locate any other methods that
would tell me where the cell was clicked or when the mouse button
was let up and where.
- (NSUInteger)hitTestForEvent:(NSEvent *)event inRect:
(NSRect)cellFrame ofView:(NSView *)controlView
is being called and I may be able to put all of my logic in here by
looking at the event information, etc., but I would like to be able
to use startTrackingAt & stopTracking if that were possible.
Is there something unique about a NSTextFieldCell that prevents
these methods from being invoked?
_______________________________________________
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
_______________________________________________
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:
@ericgorr.net
This email sent to email@hidden
_______________________________________________
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