Editing groups and mouse messages

Phil Davis revdev at pdslabs.net
Fri Oct 17 15:46:36 EDT 2008


Hi Richard,

I don't know why you're not getting a "mouseUp" at mouseUp time. As a 
workaround, I suppose you could use something like this:

on mouseMove x,y
  if sIsDragging is true then
    cancel sMyMouseUp -- stop most recent mouseUp msg from firing
    set the topleft of me to (x-xOff),(y-yOff)
    send "mouseUp" to the target in 10 milliseconds
    put the result into sMyMouseUp -- schedule another mouseUp msg
  end if
  pass mouseMove
end mouseMove

Food for thought.

Phil Davis


Richard Gaskin wrote:
> I need to build a UI similar to the Finder or Windows Explorer, in 
> which there are icons that can be moved around, and selecting one 
> brings it in front of the others.  To drag you just click and drag of 
> course, and the icon first come to the front then does the dragging 
> action.
>
> These icons are in a scrolling group, the Chipp's thread here last 
> month on relayering controls was very helpful.
>
> But I've run into a snag:  I move the object to the top of its group 
> on mouseDown, and then set my vars needed to handle the dragging so 
> they can be used later in mouseMove.  The mouseMove stuff works okay, 
> but I never get a mouseUp or mouseRelease to empty my dragging flag. :\
>
> Here's my code - the "put the params" statements in the mouseUp and 
> mouseRelease handlers don't fire:
>
>
> local sIsDragging, xOff, yOff
>
> on mousedown
>   lock screen
>   start editing grp "Main"
>   set the layer of me to top
>   stop editing
>   unlock screen
>   --
>   wait 0 with messages
>   put true into sIsDragging
>   put the mouseH-the left of me into xOff
>   put the mouseV - the top of me into yOff
> end mousedown
>
> on mouseMove x,y
>   if sIsDragging is true then
>     set the topleft of me to (x-xOff),(y-yOff)
>   end if
>   pass mouseMove
> end mouseMove
>
> on mouseUp
>   put the params
>   put empty into sIsDragging
> end mouseUp
>
> on mouseRelease
>   put the params
>   put empty into sIsDragging
> end mouseRelease
>
>
> Am I missing something here, or does editing the background muck with 
> some relationship between the target and mouse messages?
>

-- 
Phil Davis

PDS Labs
Professional Software Development
http://pdslabs.net




More information about the use-livecode mailing list