Re: Moving objects with the mouse
Re: Moving objects with the mouse
- Subject: Re: Moving objects with the mouse
- From: Jacob Lukas <email@hidden>
- Date: Thu, 23 Sep 2004 00:48:05 -0700
You would want to use mouseDown: mouseUp: and mouseDragged: of
NSResponder. You would most likely want to have the view implement
these, but the items you want to drag could also.
http://developer.apple.com/documentation/Cocoa/Reference/
ApplicationKit/ObjC_classic/Classes/NSResponder.html
It would work like this in a view:
mouseDown:
hitTest to see what object
if you've hit a draggable object
save mouse coordinates
save object
call super's mouseDown
mouseDragged:
if coordinates are set
move object the distance between old point and the mouse's current
location
call super's mouseDragged
mouseUp:
set coordinates to nil
call super's mouseUp
Jacob
On Sep 23, 2004, at 12:34 AM, Peter Karlsson wrote:
Dear list!
I have a NSView where the user programatically adds objects like
buttons, sliders and so on. I have 4 buttons where the user can move
the object in any direction, up, down, left and right. This is good
for moving the object with precision but it would be much better if
the user could move the object with the mouse, and only use the 4
buttons the last bit if needed. Can someone please tell me a simple
way to do this?
Best regards Peter
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden