Move many buttons all at same time

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Move many buttons all at same time

JosepM
Hi,

I'm trying to move some buttons all at the same time but I can't...

Only I get to move one after one.

on mouseUp
   set itemdel to tab
   set the lockMoves to true
   repeat for each line tLinea in fld "f_punts"
      put item 2 of tLinea into tObjecte
      put value(item 1 of tLinea) into tPosicio

      send "ElementMove" && value(tObjecte) & comma & value(tPosicio) to me in 0 ticks
   end repeat
   set the lockMoves to false

end mouseUp

on ElementMove pObject, pLocationX, pLocationY
   move button pObject of stack "s_tactiques_futbol" to pLocationX,pLocationY
end ElementMove


Salut,
Josep
Reply | Threaded
Open this post in threaded view
|

Re: Move many buttons all at same time

Alex Tweedly
This part always confuses me ... so this is kind of a guess. I think the
"send ...*in 0 ticks*" means that the message is queued for delivery, so
the repeat loop finishes, then the lockMoves gets set false, then
mouseUp finishes, and *then* your messages get delivered, one after another.

Try just doing

       send "ElementMove"&&  value(tObjecte)&  comma&  value(tPosicio) to me

instead of

       send "ElementMove"&&  value(tObjecte)&  comma&  value(tPosicio) to me in 0 ticks


-- Alex.




On 21/01/2011 11:04, JosepM wrote:

> Hi,
>
> I'm trying to move some buttons all at the same time but I can't...
>
> Only I get to move one after one.
>
> on mouseUp
>     set itemdel to tab
>     set the lockMoves to true
>     repeat for each line tLinea in fld "f_punts"
>        put item 2 of tLinea into tObjecte
>        put value(item 1 of tLinea) into tPosicio
>
>        send "ElementMove"&&  value(tObjecte)&  comma&  value(tPosicio) to me
> in 0 ticks
>     end repeat
>     set the lockMoves to false
>
> end mouseUp
>
> on ElementMove pObject, pLocationX, pLocationY
>     move button pObject of stack "s_tactiques_futbol" to
> pLocationX,pLocationY
> end ElementMove
>
>
> Salut,
> Josep

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Move many buttons all at same time

JosepM
Nop... They move one after one, when the first finish all the movement the next one begin the next...

Salut,
Josep
Reply | Threaded
Open this post in threaded view
|

Re: Move many buttons all at same time

dunbarxx
In reply to this post by JosepM
I know this can be scripted as you are working on it, but might it not be
easier to group your buttons, move the group, and then ungroup?

Craig Newman
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Move many buttons all at same time

sims
In reply to this post by JosepM

On Jan 21, 2011, at 3:14 PM, JosepM wrote:

>
> Nop... They move one after one, when the first finish all the movement the
> next one begin the next...

Can you group them and then move the group?

sims




_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Move many buttons all at same time

AnthonyH
If I understand requirements,

AnimationEngine does it pretty well....

A quote from Maltes animationEngine docs:

"To act on multiple controls simultanously do the following

aeLock[commandname]s
[command]
[command]
aeUnlock[commandname]s

e.g.:

aeLockWidths
aeChangeWidth the long ID of grc 1,100,1000,"bounce"
aeChangeWidth the long ID of fld 1,100,1000,"bounce"
aeUnlockWidths

This will allow you to act on multiple controls in sync, just like with aeMoveTo.


you could also try adding the name of the target controls to an array, then looping through it with the command?

on mouseUp
    put the name of btn "btn1" into controlA[1]
    put the name of btn "btn2" into controlA[2]
    repeat for each element tControl in controlA
        move tControl x,y
    end repeat
end mouseUp


cheers,

A.

On 22/01/2011, at 1:29 AM, Jim Sims wrote:


On Jan 21, 2011, at 3:14 PM, JosepM wrote:

>
> Nop... They move one after one, when the first finish all the movement the
> next one begin the next...

Can you group them and then move the group?

sims




_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Move many buttons all at same time

Randy Hengst
In reply to this post by JosepM
Hi Josep,

How about something like.....

on mouseUp
   move button "button1" relative 0,100 without waiting
   move button "button2" relative 0,100 without waiting
end mouseUp


take care,
randy hengst
-----
On Jan 21, 2011, at 8:14 AM, JosepM wrote:

>
> Nop... They move one after one, when the first finish all the movement the
> next one begin the next...
>
> Salut,
> Josep
> --
> View this message in context: http://runtime-revolution.278305.n4.nabble.com/Move-many-buttons-all-at-same-time-tp3229365p3229722.html
> Sent from the Revolution - User mailing list archive at Nabble.com.
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Move many buttons all at same time

René Micout
Elegant !

Le 21 janv. 2011 à 16:23, Randy Hengst a écrit :

> on mouseUp
>   move button "button1" relative 0,100 without waiting
>   move button "button2" relative 0,100 without waiting
> end mouseUp


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Move many buttons all at same time

Malte Brill
In reply to this post by JosepM
Hi Josep (an all),

Taking up Anthonys suggestion, here is a quick animationEngine version.

create a stack, many buttons

name one of the buttons "doIt"

set the script of btn "doIt" to

on mouseUp pMouseBtnNo
    if "animationEngine" is not among the lines of the stacksInUse then
      answer "This needs AE to run"
      exit mouseUp
    end if
    aeStopMoving "all"
    lock screen
  -- I want them to start from the center, if they should move from anywhere, comment out the repeat loop
    repeat with i=1 to the number of buttons
        if the short name of btn i= the short name of me then next repeat
        set the loc of btn i to the loc of this cd
    end repeat

    unlock screen
    aeLockMoves
    repeat with i=1 to the number of buttons
        if the short name of btn i= the short name of me then next repeat
        aeMoveTo the long id of btn i,random(the width of this cd),random(the height of this cd),1000+random(1000),any item of "in,out,inout,bounce,overshoot,"
    end repeat
    aeUnlockMoves
end mouseUp

Hope that helps,

Malte


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Move many buttons all at same time

JosepM
Hi,

Yes, now they are moving at same time but from the step 1 to step 4 directly... I have a group of steps that each button must go. But only I get move from step 1 to step 4.

I read 4 times the 6 buttons locations, but I don't see why not work :(


 set itemdel to tab

   repeat with x=0 to 4
      aeLockMoves
     
      repeat with j=1 to 6
         
         set itemdel to tab
         put item 2 of line j+(6*x) of fld "f_punts" into tObjecte
         put value(item 1 of line j+(6*x) of fld "f_punts") into tPosicio
         set itemdel to comma
         put item 1 of tPosicio into pLocationX
         put item 2 of tPosicio into pLocationY
                
         aeMoveTo the long id of btn tObjecte of stack "s_tactiques_futbol" , pLocationX,pLocationY, 4500
         
      end repeat

      aeUnlockMoves
   end repeat
   
   
Reply | Threaded
Open this post in threaded view
|

Re: Move many buttons all at same time

Malte Brill
In reply to this post by JosepM
Hi Josep,

a few questions if I may:

why the outer repeat loop?
What is in fld " "f_punts" ?

How exactly do you want your objects to move? aeMoveTo moves objects from their current position to the endposition you specify.

All the best,

Malte

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Move many buttons all at same time

JosepM
Hi Malte,

The outer repeat loop is for perform the movement of the buttons, I have X buttons that move from a initial position to a position-1, then when all the X buttons finish the movement, all move to position-2, position-3, position-n until the last position.
But all the buttons must perform the movement at same time. The user move the buttons and save the positions, move again and save again.

"f_punts" have the location and the object name.


Salut,
Josep