Using 'common' objects across multiple cards

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

gilgml
Posts: 26
Joined: Wed Jun 16, 2021 3:35 am

Using 'common' objects across multiple cards

Post by gilgml » Thu Nov 04, 2021 6:55 pm

Hey there !

I begin to use same controls on multiple cards.

It works fine with buttons.

1°) - However, the project browser is looking different as usual ( attached )
I can understand that the controls are repeated on each card, but on CARTOP, as you can see, there are blank lines...
If it is the usual behavior display for those, there is no subject :D

2°) - I began playing with fields, and for the moment i cannot share them.
Is there smthg i miss, or is it impossible ?

3°) - Many thanks in advance to the community :o
Attachments
Capture d’écran 2021-11-04 à 18.49.23.png

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

Re: Using 'common' objects across multiple cards

Post by Klaus » Thu Nov 04, 2021 7:08 pm

Hi gilgmi,

quick question: you have grouped the buttons and use the same group on your cards, right?
Or did you really make copies of your buttons and pasted them on the other cards?

1. The "project browser" is unfortuantely prone to errors (read: not the best thing in LC) :?
Close that thing, reopen and it should look fine again.

2. This is of course possible!
But you have to decide if your fields will show:
a. the SAME content on all cards or
b. different content on all cards that group is placed onto.
Check the "sharedtext" property for a. and uncheck it for b.

3. You are welcome! :-)


Best

Klaus

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10098
Joined: Fri Feb 19, 2010 10:17 am

Re: Using 'common' objects across multiple cards

Post by richmond62 » Thu Nov 04, 2021 7:17 pm

Have a look at this:
-
SShot 2021-11-04 at 20.15.27.png
-
SShot 2021-11-04 at 20.16.04.png

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Using 'common' objects across multiple cards

Post by dunbarx » Thu Nov 04, 2021 11:09 pm

What Klaus said.

But know that if you intend to do this sort of thing it is important to plan early. It is always possible to copy or clone a control onto any card in any stack. But each of those controls will have its own "existence" at that location. Any properties you set will be local.

But if you create a group on the first card in a new stack, and set its backGroundBehavior, then whenever you then create a new card, that group will automatically be copied as well. You can do this forever.

Now each of those groups still has an existence on each card, but, as Klaus mentioned, setting a field property like the "sharedText" will control whether each field contains the same text across the several groups, or separate text for each one. This takes a little practice, if you want to switch between one setting and the other. You will lose the contents of a "rogue" field if you set the sharedText back to "true" on another card.

Craig

gilgml
Posts: 26
Joined: Wed Jun 16, 2021 3:35 am

Re: Using 'common' objects across multiple cards

Post by gilgml » Fri Nov 05, 2021 10:18 am

Hello, many thanks 8)

@Klaus
1 I did the way the doc said, grouped the buttons and used the same group on subsequent cards
( navigate to other cards and Ide.Menu.Object.Place group ) like in https://lessons.livecode.com/m/4071/l/1 ... iple-cards
I did close the "project browser" and reopened it many times, but this strange display persists :(
Perhaps Richmond62 is leading me to a more reliable tool.
2 I wish the fields to share the same content.
So i will Check the "sharedtext" property and pursue this way.
Thank you :D

@Richmond62
Not sure how to use your suggestions, but I'll have a look today. Thank you :D

@dunbarx
This is a lot of information...
You guys are so experienced with this amazing tool !
Receiving answers to a single question is leading to hours and days of consequences to emerge from the flood of possibilities arousing.
Like : " But if you create a group on the first card in a new stack, and set its backGroundBehavior, then whenever you then create a new card, that group will automatically be copied as well."
Ohhh, of course i need tough planning ...
8) :D

Thank you, you made MY DAYS :shock:

stam
Posts: 3072
Joined: Sun Jun 04, 2006 9:39 pm

Re: Using 'common' objects across multiple cards

Post by stam » Fri Nov 05, 2021 10:28 am

you don't need to plan that carefully - if you have created a background group, you can add it to any card from the Object menu -> place group

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Using 'common' objects across multiple cards

Post by dunbarx » Fri Nov 05, 2021 2:48 pm

Stam
if you have created a background group, you can add it to any card from the Object menu -> place group
It is certainly possible that a shared group might need to be scattered here and there among the cards of a stack. I was pointing out that (mostly) such a group needs to be present on all cards, by the nature of the stack functionality, and using the place command is to make that happen if one did not pre-plan at the creation of card 1 is, er, a chore.

Anyway, the OP said he learned something new, and that is enough for me.

Craig

stam
Posts: 3072
Joined: Sun Jun 04, 2006 9:39 pm

Re: Using 'common' objects across multiple cards

Post by stam » Fri Nov 05, 2021 8:29 pm

Of course Craig, completely agree and no comment was intended.

I was just pointing out an additional way to do this, because with the best planning in the world outlier cases happen and it's helpful to know there is a way to do this ad-hoc, not just from new cards.

It's not that long ago I even learned about the 'place group' function at the time, and it was a revelation ;)
Of course once you've added groups this way, Craig's suggestion works as expected

Another thing i figured out the hard way is that to remove a background group from a specific card, don't deleted it, because all instances of the background group will be deleted from all cards.
Instead, use the 'remove group' menu item from the Objects menu and it will only remove it from the current card.

I mention this because it's really not clear for newcomers, as much as it's obvious to experienced LC developers...

S.

gilgml
Posts: 26
Joined: Wed Jun 16, 2021 3:35 am

Re: Using 'common' objects across multiple cards

Post by gilgml » Mon Nov 15, 2021 2:51 am

Check the "sharedtext" property to share the same content across cards...
Works fine ! Great !
if you create a group on the first card in a new stack, and set its backGroundBehavior, then whenever you then create a new card, that group will automatically be copied as well.
Delicious ! Awesome !

gilgml
Posts: 26
Joined: Wed Jun 16, 2021 3:35 am

Re: Using 'common' objects across multiple cards

Post by gilgml » Mon Nov 15, 2021 1:06 pm

@richmond62
When i use your suggestion, and observe objects with RevApplicationOverview ( Kudos ), i can see now that on the first card of the stack, i have what can be taken for duplicates fields and groups.
Capture d’écran 2021-11-15 à 03.09.07.png
They live ( ? ) in the first six lines and the two last lines.
Are this object duplicates i would have created by mistake, or ghosts created by grouping and placing activity.
Please note that meanwhile, i created a fourth card in the stack, for my eyes to see the backGroundBehavior 'auto-sharing', and it is a consequence of this on the display.
If there is a mistake here ( unwanted creation of duplicates ), how to fix it ? Because i cannot select the lines using RevApplicationOverview and i read in another thread that group editing can be tricky...
I cannot select the lines the 2nd ex of object ( ie the second line written GrpBut, the second line written BtnCar001, etccc

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7391
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Using 'common' objects across multiple cards

Post by jacque » Mon Nov 15, 2021 6:36 pm

You can click the Layer header label to see how the controls appear in their groups. It's easier to visualize the layout that way.

You do seem to have two duplicate groups. It may be that the display has not updated. Right-click on an empty space in the card overview and choose Refresh from the contextual menu.

If the duplicates remain you can delete one of them. Check the ID of the group on the fourth card and delete the other group on the third card.

Pasting a group creates a duplicate. Placing a group uses the same one across cards.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Using 'common' objects across multiple cards

Post by dunbarx » Mon Nov 15, 2021 7:08 pm

Pasting a group creates a duplicate. Placing a group uses the same one across cards.
I tried to introduce that sort of issue back up the thread:
But know that if you intend to do this sort of thing it is important to plan early. It is always possible to copy or clone a control onto any card in any stack. But each of those controls will have its own "existence" at that location. Any properties you set will be local.

But if you create a group on the first card in a new stack, and set its backGroundBehavior, then whenever you then create a new card, that group will automatically be copied as well. You can do this forever.

Now each of those groups still has an existence on each card, but, as Klaus mentioned, setting a field property like the "sharedText" will control whether each field contains the same text across the several groups, or separate text for each one. This takes a little practice, if you want to switch between one setting and the other. You will lose the contents of a "rogue" field if you set the sharedText back to "true" on another card.
There are uses and limitations for each "method". Again, takes a little practice to see how they act, and which is best for the task at hand.

Craig

gilgml
Posts: 26
Joined: Wed Jun 16, 2021 3:35 am

Re: Using 'common' objects across multiple cards

Post by gilgml » Tue Nov 16, 2021 4:08 pm

@dunbarx
i've understood that there is <> 'methods to achieve the goal.
You made it clear how to react in front of one situation or another ( say emergency vs pre-planing )
Thank you.
Now, during practice, i probably made errors.

@jacque
You can click the Layer header label to see how the controls appear in their groups. It's easier to visualize the layout that way.
OK
If the duplicates remain you can delete one of them. Check the ID of the group on the fourth card and delete the other group on the third card.
The duplicate remains :?
Now i am in an entangled situation,
On the standard project browser i see only one object ( field or group ), vs on the RevApplicationOverview i see pairs, but cannot access the second entity of objects in order to delete them. ( when i want to click the 'second' line' of a duplicate, focus escapes back to the first line.

I don't appreciate staying entangled, but don't spend your time trying to reproduce this silly situation.
I am probably going to restart from scratch, unless you give me simple guidance. :wink:

Again, thank you in advance

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7391
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Using 'common' objects across multiple cards

Post by jacque » Tue Nov 16, 2021 5:55 pm

That's very strange. If you hover your mouse over a line in the application overview you should see it's ID number. Do both groups have the same ID? That should never, ever happen but it sounds like it did.

We may be able to fix it if that's the case.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

gilgml
Posts: 26
Joined: Wed Jun 16, 2021 3:35 am

Re: Using 'common' objects across multiple cards

Post by gilgml » Tue Nov 16, 2021 8:18 pm

@jacque
Just for the record because i told you it was only the beginning of a project, so don't waste time please, both IDs are the same !
hovering first line.png
hovering 2nd line.png
And the same for 'duplicate' buttons, they share the same ID ( ex 1028 of group 1021 of card 1002 of stack Xxx )

Have a good evening

Post Reply