Page 1 of 1

choose multiple controls?

Posted: Fri Jan 09, 2015 7:26 pm
by zaxos
Hello, not sure how to explain this in english, i want the user to be able to choose multiple controls on a stack and then move them alltogether, like when you click hold on an empty area on desktop and drag it to choose whatever you want... is this possible in livecode?

Re: choose multiple controls?

Posted: Fri Jan 09, 2015 9:54 pm
by dunbarx
Hi.

You can always group the controls in question, and then move the group. If the members of the group change, you can ungroup and regroup as needed

It is also possible to move several controls using a repeat loop. (pseudo):

Code: Select all

repeat 10
lock screen
set the left of control 1 to the left of control 1 + 1
set the left of control 2 to the left of control 2 + 1
set the left of control 3 to the left of control 3 + 1
unlock screen
end repeat
Craig Newman

Re: choose multiple controls?

Posted: Sat Jan 10, 2015 6:35 pm
by zaxos
hey dunbarx, thank you for your answer, my problem isnt how to move the controls, my problem is how the user will choose the controls see the image below to uderstand

Re: choose multiple controls?

Posted: Sat Jan 10, 2015 7:02 pm
by FourthWorld
That layout seems a good fit for the DataGrid, which can handle multiple selections in custom list layouts quite well.

Re: choose multiple controls?

Posted: Sun Jan 11, 2015 1:21 am
by dunbarx
If I understand, try this. place a few buttons and one field on a card. In the card script:

Code: Select all

on mouseUp
      put the mouseControl & return after fld 1
end mouseUp
Now this is bare bones,but shows how you can select several controls and store that information.

How to initiate, how to terminate the selecting sequence and then process, how to reset, etc. are all issues to be resolved. But is this enough of a head start to get you going? Write back if I still do not know what you mean, or if I do, what other help you might need.

Craig

Re: choose multiple controls?

Posted: Sun Jan 11, 2015 3:32 am
by Simon
I think this heavily commented code is more along the lines;

Code: Select all

local tStart,tEnd,tControl,tLoc
on mouseDown
   if there is a last group then
      ungroup the last group
   end if
   put "" into tLoc
   put the number of controls of this cd into tControl
   repeat with x = 1 to tControl
      put the loc of control x  & comma & the id of control x & cr after tLoc
   end repeat
   put the mouseLoc into tStart
end mouseDown

on mouseUp
   put the mouseLoc into tEnd
   repeat for each line tLine in tLoc
      if item 1 of tline >= item 1 of tStart and item 1 of tLine <= item 1 of tEnd then
         if item 2 of tline >= item 2 of tStart and item 2 of tLine <= item 2 of tEnd then
            put "control id" && item 3 of tLine && "and " after tName
         end if
      end if
   end repeat
   if tName = "" then exit to top
   delete the last word of tName
   do "group" && tName
   set the script of the last group to "on mouseDown" & cr & \
"grab me" & cr & \
"end mouseDown" 
end mouseUp
Now that is occasionally working :)
Its more for Craig to look at.

In short
find the locations of the controls
is the location of any of the controls within the drag area
group the controls that are
grab the group

Bet you someone has a 1 liner for this :x

Simon
Edit; Oh wait.... Craig already knows this.

Re: choose multiple controls?

Posted: Mon Jan 12, 2015 4:57 am
by zaxos
Thanks alot guys, you gave me a place to start from :D