On Sep 18, 2009, at 1:21 PM, aaron smith wrote:

Ken, Yeah I read the docs. I can't figure out how to get the
-stopTracking:at:inView:mouseIsUp: method to fire.

Should I just be able to define that method and receive use that
method when the mouse is up?  Or do I have to use a combination of the
mouse tracking methods available. I've tried both and can't figure out
why that method does not fire.

These are just some random tests to see the order of how I should call
the methods. But I can't figure out why that stop method won't fire.
Any help would  be much appreciated.

- (BOOL)startTrackingAt:(NSPoint)startPoint inView:(NSView *)controlView {
        printf("START TRACKING\n");
        return NO;
}


- (BOOL)trackMouse:(NSEvent *)theEvent inRect:(NSRect)cellFrame
ofView:(NSView *)controlView untilMouseUp:(BOOL)untilMouseUp {
        printf("TRACK");
if([self startTrackingAt:NSMakePoint(cellFrame.origin.x,cellFrame.origin.y)
inView:controlView]) {
              //call the continue tracking method here
             return YES;
        }
        return YES;
}

trackMouse calls the other three; by subclassing it, you've overridden the code that calls them. Also your startTrackingAt should return YES; you want it to respond to mouse events. Either subclass the three methods (easy), or subclass trackMouse (only if you need serious customization); you generally don't need both.





- (BOOL)continueTracking:(NSPoint)lastPoint at:(NSPoint)currentPoint
inView:(NSView *)controlView {
        printf("CONTINUE\n");
        return YES;
}

- (void)stopTracking:(NSPoint)lastPoint at:(NSPoint)stopPoint
inView:(NSView *)controlView mouseIsUp:(BOOL)flag {
        printf("STOP TRACKING");
}




On Fri, Sep 18, 2009 at 10:11 AM, Raleigh Ledet <le...@apple.com> wrote:
I agree with Ken and strongly encourage you to use the three tracking
methods already defined in the NSCell documentation

raleigh.

On Sep 18, 2009, at 2:12 AM, Ken Ferry wrote:

Hi Aaron,
You should take a look at the NSCell

docs<http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSCell_Class/Reference/NSCell.html#//apple_ref/occ/instm/NSCell/trackMouse:inRect:ofView:untilMouseUp: >
.

-Ken
trackMouse:inRect:ofView:untilMouseUp:
Discussion

This method is *generally not overridden* because the default
implementation
invokes other NSCell methods that can be overridden to handle specific events in a dragging session. This method’s return value depends on the * untilMouseUp* flag. If *untilMouseUp* is set to YES, this method returns
YES if
the mouse button goes up while the cursor is anywhere; NO, otherwise. If * untilMouseUp* is set to NO, this method returns YES if the mouse button
goes
up while the cursor is within *cellFrame*; NO, otherwise.

This method first invokes

*startTrackingAt:inView:*<http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSCell_Class/Reference/NSCell.html#//apple_ref/occ/instm/NSCell/startTrackingAt:inView: >. If that method returns YES, then as mouse-dragged events are intercepted,
*

continueTracking:at:inView:*<http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSCell_Class/Reference/NSCell.html#//apple_ref/occ/instm/NSCell/continueTracking:at:inView: >
is
invoked until either the method returns NO or the mouse is released.
Finally,
*stopTracking:at:inView:mouseIsUp:*<http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSCell_Class/Reference/NSCell.html#//apple_ref/occ/instm/NSCell/stopTracking:at:inView:mouseIsUp: >
is
invoked if the mouse is released. If *untilMouseUp* is YES, it’s invoked
when the mouse button goes up while the cursor is anywhere. If
*untilMouseUp
* is NO, it’s invoked when the mouse button goes up while the cursor is within *cellFrame*. You usually override one or more of these methods to
respond to specific mouse events.


On Fri, Sep 18, 2009 at 1:33 AM, aaron smith <
beingthexemplaryli...@gmail.com> wrote:

What's the proper way of handling simple mouse events in NSCell's?
Like mouseUp, mouseDown, etc.

I see that an NSControl implements NSResponder, but wasn't sure if
that's the right way to do it. Because of the fact that tables usually use cell's rather than a control. I've also been looking at the method
trackMouse:inRect:ofView:untilMouseUp: but this method doesn't ever
get fired when the mouse is up.

Any ideas?
Thanks.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/kenferry%40gmail.com

This email sent to kenfe...@gmail.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/ledet%40apple.com

This email sent to le...@apple.com


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/lrucker%40vmware.com

This email sent to lruc...@vmware.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to