choose multiple controls?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
zaxos
Posts: 222
Joined: Thu May 23, 2013 11:15 pm

choose multiple controls?

Post by zaxos » Fri Jan 09, 2015 7:26 pm

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?
Knowledge is meant to be shared.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10354
Joined: Wed May 06, 2009 2:28 pm

Re: choose multiple controls?

Post by dunbarx » Fri Jan 09, 2015 9:54 pm

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

zaxos
Posts: 222
Joined: Thu May 23, 2013 11:15 pm

Re: choose multiple controls?

Post by zaxos » Sat Jan 10, 2015 6:35 pm

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
Attachments
Untitled.png
Knowledge is meant to be shared.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10058
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: choose multiple controls?

Post by FourthWorld » Sat Jan 10, 2015 7:02 pm

That layout seems a good fit for the DataGrid, which can handle multiple selections in custom list layouts quite well.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10354
Joined: Wed May 06, 2009 2:28 pm

Re: choose multiple controls?

Post by dunbarx » Sun Jan 11, 2015 1:21 am

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
Last edited by dunbarx on Sun Jan 11, 2015 6:08 am, edited 2 times in total.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: choose multiple controls?

Post by Simon » Sun Jan 11, 2015 3:32 am

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.
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

zaxos
Posts: 222
Joined: Thu May 23, 2013 11:15 pm

Re: choose multiple controls?

Post by zaxos » Mon Jan 12, 2015 4:57 am

Thanks alot guys, you gave me a place to start from :D
Knowledge is meant to be shared.

Post Reply