Navigating Cards with Reusable Buttons

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: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
booee
Posts: 2
Joined: Fri Mar 27, 2015 9:48 pm

Navigating Cards with Reusable Buttons

Post by booee » Mon Oct 22, 2018 9:30 pm

I have 3 buttons with scripts for each that navigate respectively through 3 different cards
(button 1 goes to card 1, button 2 to card 2, etc).

I would like to have these 3 buttons along all 3 cards.
The issue is this:
I can copy the buttons to each card, but if I later make changes to the code of style of the button on card one, it won't copy those changes to all of the card buttons.

Is there a way to create reusable components (such as buttons), where I create it once and drag it to the different cards, and one change will change them all?
If not, what is the best practice for creating reusable components (such as buttons) that accomplishes what I'm seeking (efficiency).

Thanks!

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

Re: Navigating Cards with Reusable Buttons

Post by dunbarx » Mon Oct 22, 2018 9:55 pm

Hi.

Yes.

Two experiments:

1- In a new stack, drag three buttons onto the card. Select them all and group them. Select "backGroundBehavior" in the property inspector for the group.

Now make a new card. The group appears there, and on every new card you make.

2- If you already have objects, then group them, and use the "place" command to create a copy on any card you want to. Read up on the "place" command, you will see that simply using it automatically sets the backGroundBehavior property.

The real lesson here is to plan, as best you can, in advance. I never do.

Craig Newman

booee
Posts: 2
Joined: Fri Mar 27, 2015 9:48 pm

Re: Navigating Cards with Reusable Buttons

Post by booee » Mon Oct 22, 2018 10:34 pm

Amazing! Thank you so much, Craig!

Yup, I too am also very bad a planning ahead, so I'm trying to do my best as I port an old project over to LiveCode.

This information is gold though, and I'm really surprised it hasn't been featured in any lessons,etc.
There really should be a educational portion for "Planning your project" that gives best practices such as this.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”