Drag & drop controls inside a scroller

Paul Hibbert lc at pbh.on-rev.com
Thu Oct 18 12:30:45 EDT 2012


Hi Josep,

Your code stops at line 11 where the word status has wrapped to a new line and so has dropped out of the comment, also at line 13.

It gives this error in the 'Errors" pane of the Script Editor:
	button "Button": execution error at line 11 (Handler: can't find handler) near "status", char 1

This is because LC now thinks "status" is a handler, but that handler isn't defined.

Move the word "status" back to the commented line, do the same with line 13 and the code works fine.

Note, you should also enclose the field name in quotes.

Paul

New code:

   local allowDrag
   on mouseDown
     put (the mouseH - left of me),(the mouseV - top of me) into allowDrag
   end mouseDown

   on mouseMove x,y
        if allowDrag = "" then exit mouseMove
    set topLeft of me to \
                  (x - item 1 of allowDrag) & "," & (y - item 2 of allowDrag)
   # if within(grc box1,loc of me) then put "You hit box 1" into fld "status"
   # if within(grc box2,loc of me) then put "You hit box 2" into fld "status"
        put "" into fld "status"
        if intersect(me,grc box1) then put "You hit box 1" into fld "status"
        if intersect(me,grc box2) then put "You hit box 2" into fld "status"
   end mouseMove

   on mouseUp
     put empty into fld "status"
     put "" into allowDrag
   end mouseUp

   on mouseRelease
     mouseUp
   end mouseRelease


 
On 2012-10-17, at 11:09 PM, JosepM wrote:

> Hi,
> 
> I need help to drag and drop controls inside a scroller.
> Someone have any experience about? Grab me don't work nor the classic drag
> and drop operations.
> 
> I found a great sample from Scoot Rossi showing the misteries of drag and
> drop
> 
> http://www.tactilemedia.com/site_files/downloads/drag_sampler.rev
> 
> That run fine on iOS, but using the same inside the scroller no.
> 
> 
>    local allowDrag
>    on mouseDown
>      put (the mouseH - left of me),(the mouseV - top of me) into allowDrag
>    end mouseDown
> 
>    on mouseMove x,y
>      if allowDrag = "" then exit mouseMove
>      set topLeft of me to \
>          (x - item 1 of allowDrag) & "," & (y - item 2 of allowDrag)
>      # if within(grc box1,loc of me) then put "You hit box 1" into fld 
> status
>      # if within(grc box2,loc of me) then put "You hit box 2" into fld
> status
>      put "" into fld status
>      if intersect(me,grc box1) then put "You hit box 1" into fld status
>      if intersect(me,grc box2) then put "You hit box 2" into fld status
>    end mouseMove
> 
>    on mouseUp
>      put empty into fld status
>      put "" into allowDrag
>    end mouseUp
> 
>    on mouseRelease
>      mouseUp
>    end mouseRelease
> 
> 
> 
> This is the code inside of the button that I want drag. The control move
> only a few pixels and stop...
> 
> Any idea?
> 
> 
> 
> --
> View this message in context: http://runtime-revolution.278305.n4.nabble.com/Drag-drop-controls-inside-a-scroller-tp4656481.html
> Sent from the Revolution - User mailing list archive at Nabble.com.
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list