[Newbies] Re: Constrained Morph dragging
sebnozzi at gmail.com
Sun Nov 18 13:29:06 UTC 2012
I came up with this... does what I need and I have no visual
artifacts anymore. Still, I'm not happy for having to override a
private method in order for this to work... :-/
Overridden existing method in my Morph subclass:
super privateFullMoveBy: delta.
(self wantsToConstrainDragging & self isBeingDragged)
ifTrue: [ self adjustPositionWhileDragging ]
New methods in my Morph subclass:
^ self owner isHandMorph
self position: (self constrainedDragPositionFrom: (self topLeft))
"Adjust the position to be constrained however you want. In this case
horizontally at y=450"
^ (aNonConstrainedPosition x) @ 450.
You would need to override only "wantsToConstrainDragging" and
Any critique to the code and/or naming welcome! :-)
More information about the Beginners