Create substack as part of a card

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
mrcoollion
Posts: 719
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Create substack as part of a card

Post by mrcoollion » Tue Jan 11, 2022 12:36 pm

Hello all smart people.

I have the following problem, maybe any of you much smarter developers can help me.
Problem:
I have a card in my stack that has a lot of fields and code in it. I need to have multiple version of this card because for each version a few fields and some code is different. This means that if I change something in the generic part of this card I need to do this for all others as well.

My Idea was to use SubStacks that hover over this card as if it is part of the card, and for each different situation call a different substack that lays over this card (as if it is part of the card). This way I only have to make and open different substacks for each different situation and keep the main card the same which makes it easier to change and maintain.

I have tried this but could not make is so that a substack looks like it is part of an existing card (e.g. no border lines, no Top and so on, link it to a position in the main card).

Do any of you have some tips or even better an example for me?

Regards,

Paul

SparkOut
Posts: 2839
Joined: Sun Sep 23, 2007 4:58 pm

Re: Create substack as part of a card

Post by SparkOut » Tue Jan 11, 2022 1:46 pm

On the "master" card, if the common fields will all reflect any changes on the other cards then select the "shared text" option in the property inspector.
Group all the common fields and objects. Select the "behave as a background" option in the property inspector.
Then any NEW cards you create will have those common objects included.
On the other cards, delete any "duplicated" objects.
Then in the edit menu choose "place" and select the "background group". This will add those same common objects to any cards that are pre-existing, as opposed to the automatic inclusion on new cards.

Then the rest of the objects on each card will be individual to that card, but all the common stuff can easily be maintained.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9580
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Create substack as part of a card

Post by dunbarx » Tue Jan 11, 2022 3:24 pm

Sparkout is likely spot on, but assumes that the same fixed group of controls are constant throughout, and only fixed outliers need to be different. if so, that is certainly the best and most robust method.

If not, it is possible to identify certain controls, perhaps by including some "tag" in their names, and clone those whenever you make a new card. Then any other controls will be the ones that are locally different, and you will know which ones they are, because if you loop through all controls on the new card, you can get a list of untagged ones.

Craig

andresdt
Posts: 146
Joined: Fri Aug 16, 2019 7:51 pm

Re: Create substack as part of a card

Post by andresdt » Tue Jan 11, 2022 3:59 pm

hi @mrcoollion
:idea: Another idea would be to create a group with the controls that are common. Then create one for each variant and all you have to do is. On the same card, hide and show groups as needed

mrcoollion
Posts: 719
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Re: Create substack as part of a card

Post by mrcoollion » Wed Jan 12, 2022 1:13 pm

Thanks for all the idea's :D

Using "shared text" option in the property inspector and group all the common fields and objects and select the "behave as a background" option in the property inspector was not an option because i already have a template card set up this way.
However after some tinkering what I tried to do I have partly achieved (see attached stack).

The only snag is that any window can still come between the substack and main stack.
For me this is not a big issue but it would be nice if this could be prevented.
Also I cannot seem to change the background color of the SubStack_01 (changed it once cannot change it back???)
SubStack_02 has the same color (default) as the card it is layered on so therefore I put a button on it to see something appearing.

Any ideas to improve this are very welcome.
MultipleSubstacksOnOneCard_V01.zip
Multiple Stacks on one card
(1.9 KiB) Downloaded 80 times
Friendly greetings

Paul

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9580
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Create substack as part of a card

Post by dunbarx » Wed Jan 12, 2022 3:09 pm

Paul,

Can you use the "mode" property to set the "order" of the "topStacks"? If you meant a window from another application, I do not think so, but within LC you can surely manage this.

Craig

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Create substack as part of a card

Post by jacque » Wed Jan 12, 2022 6:10 pm

Using substacks to simulate card additions sounds like trouble to me, there are too many things that could go wrong. If you can't use the ideas posted here, use groups instead. They will appear as part of the card and do what you want.

I don't understand how your existing template is involved though, so maybe I'm off track.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9580
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Create substack as part of a card

Post by dunbarx » Wed Jan 12, 2022 6:40 pm

Another important point.

If you can possibly know that this sort of thing is going to be part of your stack, it really helps to set up the background groups at the very outset. That way you do not have to "place" controls all day.

But again, unless the "fixed" group of controls is, er, fixed, and only the outliers change, then you have to fiddle around constantly. In that case you need a plan to identify the changelings. You might also consider using behaviors to execute common code. At least these sit "outside" the card paradigm.

Craig

mrcoollion
Posts: 719
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Re: Create substack as part of a card

Post by mrcoollion » Fri Jan 14, 2022 10:28 am

Again thanks for all the valuable tips. :D

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”