Putting a graphic into a group

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
mtecedor
Posts: 68
Joined: Fri Sep 04, 2009 6:40 pm

Putting a graphic into a group

Post by mtecedor » Thu Nov 12, 2009 7:27 pm

Hi All,

I am having problems moving a line created by the end user into an already existing group.

This is the scenario:

I have a small group containing a really small image.

When the end user click on a button, (s)he can draw a line the size (s)he wants.
This is the code in the button:

on mouseUp
put the number of graphics of this card into tGraphicNo
choose graphic tool

--Creates a line with the following characteristics
set the style of the templateGraphic to "line"
set the lineSize of the templateGraphic to 2
set the endArrow of templateGraphic to true
set the startArrow of templateGraphic to true
set the arrowSize of templateGraphic to 4
set the foregroundColor of templateGraphic to "red"

-- put width and height of new line into variable
put the width of templateGraphic into tWidthGraphic
put the height of templateGraphic into tHeightGraphic
--name the new line
set the name of templateGraphic to "lineclone" & tGraphicNo
end mouseUp

Then I resize the group to be the same size as the line.

This is the code in the card:
on newGraphic
choose browse tool
clone group GLine
put the number of groups of this card into tGroupNo
set the name of last group to "LClone" & tGroupNo
set the invisible of group ("LClone" & tGroupNo) to false

--resize group
set the width of group ("Lclone" & tGroupNo) to the width of graphic ("lineclone" & tGraphicNo)
set the height of group ("Lclone" & tGroupNo) to the height of graphic ("lineclone" & tGraphicNo)
end newGraphic


Then, I need to put that line into the group.

I have tried with the put command, but it tells me that the group is not a container.

Then i have tried with the start/stop editing commands, but it doesnt work. If I put them into the button, it tells me that it cannot find the background. If I put it into the card, it tells me that it cannot find the background in the stop editing command.

Any ideas? Is there any other simpler way to do it?

Thanks

Marta

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Thu Nov 12, 2009 9:09 pm

You can set the relayerGroupedControls global property to reue, and then change the layer of your newly created line graphic to move it into the group.

HTH,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Post by mwieder » Fri Nov 13, 2009 2:26 am

There's a bug in the "stop editing" command. *Don't* use the group name.

These work (usually):

Code: Select all

stop editing group
stop editing background
This doesn't:

Code: Select all

stop editing group "LClone"

mtecedor
Posts: 68
Joined: Fri Sep 04, 2009 6:40 pm

Post by mtecedor » Fri Nov 13, 2009 4:03 am

Thanks for your replies.

I think I found a way around. I ungroup the group, and then, put my image and the new line into a new group. Maybe its not very elegant, but it works.

Marta

Post Reply