Group Locations

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
bsouthuk
Posts: 261
Joined: Fri Dec 05, 2008 7:25 pm

Group Locations

Post by bsouthuk » Sun Dec 12, 2010 8:55 pm

Hi Guys

I have been banging my head against the wall over the last couple of days trying to work out a way of placing groups so that they are aligned and placed on above each other with no overlap.

Is there a short script I can use so that if i click a button that all groups that are visible on a card are placed neatly aligned to the left and directly above each other?

You help would be most appreciated!

Thanks


Daniel

WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm

Re: Group Locations

Post by WaltBrown » Mon Dec 13, 2010 12:21 pm

Did you try something like?

Code: Select all

    local tTop, tLeft, tGrp, tGrpList
    -- Put list of grps affected into tGrpList

    put <desired starting top location> into tTop
    put <desired left location> into tLeft
    repeat for each grp tGrp in tGrpList
       set the topLeft of grp tGrp to tLeft,tTop
       put the bottom of grp tGrp into tTop
    end repeat
Or does the change to the boundary when you group the objects mess it up?
Walt Brown
Omnis traductor traditor

bsouthuk
Posts: 261
Joined: Fri Dec 05, 2008 7:25 pm

Re: Group Locations

Post by bsouthuk » Mon Dec 13, 2010 1:01 pm

Hi! Thanks for this - I have tried the script but get the folllowing error message:

button "Button": compilation error at line 7 (repeat: bad termination condition) near "tGrp", char 12

Klaus
Posts: 14208
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Group Locations

Post by Klaus » Mon Dec 13, 2010 1:56 pm

Hi Daniel,

unfortunately "repeat for each..." does not work with object on cards!
Use "repeat with i = 1 to the num of grps..." instead.

But please post your complete script to be sure!


Best

Klaus

WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm

Re: Group Locations

Post by WaltBrown » Mon Dec 13, 2010 2:42 pm

Sorry, I was too quick. I put this in a button and made 3 groups, G1, G2, and G3.

Code: Select all

on mouseUp
   local tTop, tLeft, tGrp, tGrpList, tGrpNum
    put "g1" & comma & "g2" & comma & "g3" into tGrpList
    put 50 into tTop
    put 50 into tLeft
    repeat with tGrpNum = 1 to the number of items in tGrpList
       put item tGrpNum of tGrpList into tGrp
       set the topLeft of grp tGrp to tLeft,tTop
       put the bottom of grp tGrp into tTop
    end repeat
end mouseUp

Walt Brown
Omnis traductor traditor

bsouthuk
Posts: 261
Joined: Fri Dec 05, 2008 7:25 pm

Re: Group Locations

Post by bsouthuk » Mon Dec 13, 2010 2:47 pm

Briliant thank you very much!!!

What actually determines the gap in between each group?

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: Group Locations

Post by bn » Mon Dec 13, 2010 4:03 pm

Hi Daniel,

it is the borderwidth of the group (if shown and greater than 0) and the margins of the group. Look in the properties inspector -> Text formatting. Set the margins to 0 and if the border is not shown then you will see the groups stacked upon each other.

regards

Bernd

bsouthuk
Posts: 261
Joined: Fri Dec 05, 2008 7:25 pm

Re: Group Locations

Post by bsouthuk » Mon Dec 13, 2010 4:06 pm

wow - that simple, fantastic. Thank you for your help!

Post Reply