Re: Mouse button down?
Re: Mouse button down?
- Subject: Re: Mouse button down?
- From: John Randolph <email@hidden>
- Date: Tue, 6 Apr 2004 19:30:44 -0700
On Apr 3, 2004, at 2:19 PM, Sam McCandlish wrote:
On Apr 3, 2004, at 4:56 PM, mmalcolm crawford wrote:
On Apr 3, 2004, at 12:24 PM, Peter Wollschlaeger wrote:
you should override in a custom view mouseDown like:
- (void)mouseDown:(NSEvent *)theEvent
{
NSPoint p = [theEvent locationInWindow];
p.x -= [self frame].origin.x;
p.y -= [self frame].origin.y;
}
If this code is intended to get the point's location in your own
coordinate space, in the general case it is incorrect. You should
use:
- (void)mouseDown:(NSEvent *)theEvent
{
NSPoint p = [theEvent locationInWindow];
p = [self convertPoint:p fromView:nil];
}
Thanks all, but what I actually wanted was to, at any point in time,
whether the app is active or inactive, and whether or not the the
mouse is in "my" window, test to see if the mouse button is down. I
need to do this because I don't want a specific action to happen
(which should happen whenever the mouse is up) to happen when the
mouse is down.
It's a little wasteful, but Button() will check whether the mouse
button is down at the moment you call it. Just don't call it in a
loop, please.
-jcr
John C. Randolph <email@hidden> (408) 974-8819
Sr. Cocoa Software Engineer,
Apple Worldwide Developer Relations
http://developer.apple.com/cocoa/index.html
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.