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:

privateFullMoveBy: delta
        super privateFullMoveBy: delta.
        (self wantsToConstrainDragging & self isBeingDragged)
                ifTrue: [ self adjustPositionWhileDragging ]

New methods in my Morph subclass:

isBeingDragged
        ^ self owner isHandMorph
        
wantsToConstrainDragging
        ^ true  

adjustPositionWhileDragging
        self position: (self constrainedDragPositionFrom: (self topLeft))
        
constrainedDragPositionFrom: aNonConstrainedPosition
        "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
"constrainedDragPositionFor:".

Any critique to the code and/or naming welcome! :-)

Cheers,

Sebastian

Reply via email to