Help with adding button
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Help with adding button
Is there a way to add a single button to every card in an entire stack at the same time? and i don't already have a group of buttons i can just add the button to
-
- Livecode Opensource Backer
- Posts: 447
- Joined: Mon Jan 23, 2012 12:46 pm
Re: Help with adding button
This should work for you:
Hope that helps,
--Sefro
Code: Select all
repeat with x = 1 to the number of cards in this stack
if there is not a button "MyButton" of cd x then
copy btn "MyButton" of cd "CardWithButton" to cd x
end if
end repeat
--Sefro
Re: Help with adding button
i know this sounds dumb but where do i put that code?
Re: Help with adding button
is there a way to place a group of buttons on every card in a stack at once?
-
- Livecode Opensource Backer
- Posts: 447
- Joined: Mon Jan 23, 2012 12:46 pm
Re: Help with adding button
Well, you could just make a new button, and add that script between the mouseup handler, also changing the names of the button/card to the ones in your stack. Once you press it it will automatically add the button to every card in your stack, then you can just delete the extra button once it has done it's work. To answer your second question: You can set up a group, and check off "behave like a background" in the property inspector/ Every card you create after that will have this group on it. If you already have the cards created (which it sounds like you do) you could easily create a group and use basically the same script I posted above to copy it to each card.
HTH,
--Sefro
Edit: I will, as others have before me, encourage you to check out these stacks : http://www.hyperactivesw.com/revscriptc ... ences.html
They contain a wealth of LiveCode knowledge.
HTH,
--Sefro
Edit: I will, as others have before me, encourage you to check out these stacks : http://www.hyperactivesw.com/revscriptc ... ences.html
They contain a wealth of LiveCode knowledge.
-
- Livecode Opensource Backer
- Posts: 447
- Joined: Mon Jan 23, 2012 12:46 pm
Re: Help with adding button
This may be overkill, but I came up with this function:
You can throw this into your stack script, and then use it from the message box (or in a script) like this:
or
or
This function will copy the referenced control to all cards in a stack that do not already contain one. I'm not sure if this is actually useful, and make no warranties, but I was bored and this is what I came up with
--sefro
Code: Select all
function CopyToAll tObjType,tObjName,tCDname
put"if there is not a"&&tObjType"e&tObjName"e&"of cd x then" &cr into tScript
put "copy"&& tObjType"e&tObjName"e&&"of cd"&"e&tCDname"e&&"to cd x" & cr after tScript
put "end if" after tScript
repeat with x = 1 to the number of cards in this stack
do tScript
end repeat
end CopyToAll
Code: Select all
copytoall("group","mygroup","CardWithMyGroup")
Code: Select all
copytoall("button","mybutton","CardWithMybutton")
Code: Select all
copytoall("graphic","mygraphic","CardWithMyGraphic")
--sefro