Re: is the mouse button pressed?
Re: is the mouse button pressed?
- Subject: Re: is the mouse button pressed?
- From: Ian <email@hidden>
- Date: Wed, 29 May 2002 10:39:51 +0100
Thanks Randy, I'm familiar with NSResponder, and the way it works, but
it's not what I require in this situation. Overiding the
mouseUp/Down/Dragged methods only tells me when one of these events has
occurred within one of my views. What I need is to ask the system "is
the mouse down right now?", kind of globally, rather than on a per view
basis. My app has many views which all implement their own mouseDown etc
methods, but I'd like to know at a certain time, unrelated to any of
these events simply is the mouse down or not:)
My particular problem is this...
My window has an NSOpenGLView with some appKit controls floating above
it in a borderless transparent window, and when the main window moves I
need to hide the floating controls window until the main window has
stopped moving, so that I can unhide the floating window in the correct
place.
I'm hiding the transparent floating window in windowWillMove and showing
it again in windowDidMove. When the user starts to drag the window I get
my willMove notification, but if they stop moving it and don't release
the mouse (ie still clicked on the window's title bar) I get the didMove
note as expected, but when the user resumes moving the window, the
willMove note doesn't come, so my floating controls don't hide and sit
there, snapping into the correct location when the user releases the
button, or stops moving the mouse.
It seems that windowWillMove only comes with a click on the title bar
(which is reasonable).
I've tried subclassing NSWindow so that I can overide mouseDown, but
clicks in the title bar go somewhere else (the window server perhaps?)
and I've also tried overiding the setFrame... methods but they only get
called when the user has finished moving the window.
So... I thought the easiest way round all of this would be, in my
windowDidMove method, only to show the floating window again if the user
had released the mouse button... guaranteeing that the window move
operation had finished. It seems that mouse down and up events aren't
accessible when they 'belong' to a window's title bar, hence my need to
ask the system to check with the mouse to see if the button's down.
Thanks for you advice anyway! :)
Ian
On Wednesday, May 29, 2002, at 02:49 AM, Randy Zauhar wrote:
>
Ian, indeed there were toolbox functions that do just what you say -
>
I've used them!
>
>
In nextstepLand, mouse events are being intercepted by an NSView, which
>
is a subclass of NSResponder, which includes the methods
>
>
- (void)mouseDown:(NSEvent *)theEvent
>
- (void)mouseDragged:(NSEvent *)theEvent
>
- (void)mouseUp:(NSEvent *)theEvent
>
>
and others. These methods are invoked whenever a mouse event is
>
intercepted by the NSView that owns them. You need to override these
>
methods in your custom subclass of NSView to implement whatever
>
behavior you want. Or at least that's my understanding - I'm just
>
implementing this now. If I'm wrong, there are lots of knowledgeable
>
people on the list who will tell you different.
>
>
Randy
>
>
P.S. How come you didn't find that in the docs? Isn't it OBVIOUS that
>
'mouseDown' should be found in NSResponder? ;-)
>
>
On Tuesday, May 28, 2002, at 08:03 PM, Ian wrote:
>
>
> In the Mac OS(<10) toolbox we had a function, I think it was
>
> mousepressed() or mousedown() or buttondown() or something which
>
> simply told us whether or not at that instant the mouse button was
>
> down. I could really use something like that now, but can't find a
>
> cocoa equivalent. I don't want to overide mouseDown or poll [NSApp
>
> currentEvent] or anything like that, I just want to know that at the
>
> instant I call
>
> NSImaginaryMethodThatReturnsYesOrNoAccordingToAnyMouseButtonBeingDownOrNot
>
> will let me know what I want to know :)
>
>
>
> Have I missed this somewhere? Many thanks to anyone that can tell me
>
> yes or no if this functionality already exists.
>
> _______________________________________________
>
> 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.
>
>
>
>
>
>
Randy J. Zauhar, PhD
>
Assoc. Prof. of Biochemistry
>
Director, Graduate Program in Bioinformatics
>
University of the Sciences in Philadelphia
>
Dept. of Chemistry & Biochemistry
>
600 S. 43rd Street
>
Philadelphia, PA 19104
>
>
Phone: (215)596-8691
>
FAX: (215)596-8543
>
E-mail: email@hidden
>
Web: http://tonga.usip.edu/zauhar
_______________________________________________
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.