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 15:23:02 +0100
Randy,
I do have controls and openGL in the same window (side by side), it's
just that I wanted a couple of controls to actually sit _on top of_ the
oGL view, and until Jaguar the only way to do this is to float a
borderless transparent window over the top of it. Hiding the controls so
they don't get left behind as the main window is dragged, and reshowing
at the correct time is proving to be a bit of a pain.
Also, thanks to Gregory Weston for letting me know that Button() is
alive and well, but alas this isn't the answer I thought it'd be, as the
user has to let go of the button at the very instant they stop moving
the window.
And now the good news:
I've just gone over subclassing NSWindow again, and discovered that
although mouseDown and mouseUp in a title bar are unreachable, the
window *does* get sent mouseDragged during window moving, so I'll be
able to solve my problem fairly trivially this way! :)
Thanks again to everyone that helped.
Ian
On Wednesday, May 29, 2002, at 02:49 PM, zauhar wrote:
Sorry Ian, you have a much more sophisticated problem then was apparent
from the wording of your message. I do understand what you're trying to
do.
Why can't you have your controls and the openGL view together in the
same window?
My sense of the Application Kit is that it is NOT designed to give you
access to low-level stuff like in the old Mac Toolbox. Are there any
functions in Carbon that can do that? Apparently people routinely mix
carbon calls along with Cocoa.
All the best,
Randy
On Wednesday, May 29, 2002, at 05:39 AM, Ian wrote:
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.
Randy J. Zauhar, PhD
Assoc. Prof. of Biochemistry
Director, Graduate Program in Bioinformatics
Dept. of Chemistry & Biochemistry
University of the Sciences in Philadelphia
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
Thought for the ages:
"If you have conceptions of things that you can have no conception of,
then the conception and the thing appear to co-incide." -- C.G. Jung
Thought for the new millennium:
"Nothing is gooder than watching cartoons." -- Catherine Zauhar, age 5
_______________________________________________
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.