Reliable Custom Window Dragging in LC7?

Mike Bonner bonnmike at
Sun Aug 9 08:24:30 CEST 2015

Just tried it here, this old script seems to work fine for me 7.0.6..
<-- source

Sorry if you've already tried this method.

*local* sgDragging, sgLeftOffset, sgTopOffset

*on* mouseDown
    *put* item 1 of the mouseLoc into sgLeftOffset
    *put* item 2 of the mouseLoc into sgTopOffset
    *put* true into sgDragging
*end* mouseDown

*on* mouseMove
    *lock* screen
    *if* sgDragging is true *then*
        *set* the left of this stack to item 1 of globalloc(the mouseLoc) -

        *set* the top of this stack to item 2 of globalloc(the mouseLoc) -
    *end* *if*
    *unlock* screen
*end* mouseMove

*on* mouseRelease
    *put* false into sgDragging
*end* mouseRelease

*on* mouseUp
    *put* false into sgDragging
*end* mouseUp

On Sat, Aug 8, 2015 at 10:56 PM, Scott Rossi <scott at> wrote:

> Hi All:
> Is anyone still making custom-shaped stacks out there that use scripts to
> manage window dragging?
> I've noticed for some time now that custom window drag routines which used
> to work in all past versions of LiveCode now seem to be ineffective in
> LC7.  For example, if you have a couple of stacks with custom windowShapes
> and click/drag to reposition them, it takes LiveCode several cycles to
> make the window active and catch up with the cursor position.  And when
> the stack finally starts moving, it's position is way off from where the
> click first occurred on the stack.
> To work around this problem, I figured out a new dragging routine that
> seems to work pretty reliably, but it relies on some tactics that have
> been discouraged in the past, such tracking the screenMouseLoc and polling
> the mouse state.  Here's the script I'm using (applied using a behavior):
> local mLoc
> before mouseDown
>    trackDrag
> end mouseDown
> command trackDrag
>    repeat while the mouse is "down"
>       put the screenMouseLoc into SML
>       set topLeft of this stack to item 1 of SML - item 1 of mLoc,\
>       item 2 of SML - item 2 of mLoc
>    end repeat
> end trackDrag
> before mouseMove X,Y
>    put X,Y into mLoc
>    pass mouseMove
> end mouseMove
> I know there aren't a ton of people building stacks with custom
> windowShapes and appearances out there.  And while the above has been
> working for me for a while now, I'm still curious if anyone else has run
> into this and come up with an alternate solution.
> Thanks & Regards,
> Scott Rossi
> Creative Director
> Tactile Media, UX/UI Design
> _______________________________________________
> use-livecode mailing list
> use-livecode at
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:

More information about the use-livecode mailing list