Page 1 of 1

Background Menu Button w/ Different Value on Different Cards

Posted: Sun Dec 25, 2016 5:58 pm
by idenr
Is there any way to have a menu button with multiple choices that is shared on all the cards in a stack but whose value can be different on different cards depending on what is chosen on that card? Is the only way to do this to make this a non shared button? Reason being I'd like the new card command to duplicate all the buttons and fields on the card without having to create an on newcard script that has to go through and recreate each button and field from scratch?

Re: Background Menu Button w/ Different Value on Different C

Posted: Sun Dec 25, 2016 6:19 pm
by Klaus
Hi idenr,

1. welcome to the forum! :D

2. It is good style to also answer/comment your previous posting(s) before asking new questions:
http://forums.livecode.com/viewtopic.ph ... 94#p148694

3. This is not possible per se, but you can group a single button and place this group onto every card you want to
and use a "pre-/opencard" script to fill the same button with new content on every card it has been placed.
Know what I mean?


Best

Klaus

Re: Background Menu Button w/ Different Value on Different C

Posted: Mon Dec 26, 2016 4:42 am
by dunbarx
Everything that Klaus said.

To expand just a bit. Do you know that a field has a "sharedText" property, whereby if true, one can display the same text in that field on each card, and different text in that same field if "false"? The fields can hold both at the same time, the actual displayed text depending on the current state of that property.

But a button has no such property (or you might say that its "sharedTet" property is always "false"). Its contents have to be local to the card it is resident on , even though it is a grouped button with backGroundBehavior set to "true". So at least you can create a new card and that button will appear automatically. When Klaus suggested that the contents be set upon preOpenCard, those contents might be stored in a custom property of that card or as a set of properties of the stack, pulled as needed.

As Klaus says, see what we mean?

Craig Newman

Re: Background Menu Button w/ Different Value on Different C

Posted: Mon Dec 26, 2016 6:02 pm
by idenr
Thank you very much for your help.

What I found was that as you said fields can be "background" grouped fields and either share or not share their contents. With the buttons the answer is to make the buttons not part of the group but to copy each button from a template card to the new card inside a newcard handler. Then the buttons can each hold a different value on different cards.

Re: Background Menu Button w/ Different Value on Different C

Posted: Mon Dec 26, 2016 8:29 pm
by dunbarx
Certainly this will work. It is just not as robust, in my opinion. When you make a new card, you copy its structure from (I assume) the templateCard and then explicitly set the contents of the button. If you have to change those contents, you need to access the card itself. Well and good, as far as that goes.

I feel more comfortable with a single background group. I can manage button and card properties, changes, deletions, whatever, from a single source, perhaps a short handler in the stack script. How that is actually done is wide open.

It may simply be a matter of style.

Craig