Creating user interface

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

Post Reply
germanBUSAwQm
Posts: 1
Joined: Wed Jan 23, 2013 5:29 pm

Creating user interface

Post by germanBUSAwQm » Wed Feb 06, 2013 8:03 pm

Is it possible to create an interface with header and footer and repeat it in all cards of a stack?

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

Re: Creating user interface

Post by jacque » Wed Feb 06, 2013 8:40 pm

Sure. Create them as groups, set the group's backgroundBehavior to true (in the inspector) and place the group on each card that should show it. Don't copy/paste the group, that will create multiple copies of it. Instead use the "place group" menu item in the Objects menu.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

acidjazz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 93
Joined: Mon Feb 16, 2009 2:37 am
Location: Tampa, FL

Re: Creating user interface

Post by acidjazz » Wed Feb 06, 2013 9:57 pm

Probably a few other things should be mentioned, and Jacque, I'd love to hear your comments on these since they used to (and occasionally still do) confuse me.

If you want the background on ALL cards, then create it on Card 1, check backgroundBehavior, like Jacque said, and then just rightclick and create new card (or choose it from the Object pulldown menu). The background will be placed automatically on each new card you create.

If you want the background on SOME cards, but not others, then you have to uncheck backgroundBehavior when you create the new card (that you want to be blank). You can't selectively delete the background after the fact. If you try to delete on one card, it'll delete on all cards (regardless of whether you uncheck the backgroundbehavior button). You'll get a warning, but once it's gone, it's gone.

So, let's say you've got the background on Cards 1 and 2, then didn't put one on Card 3, and now you want the same background on a new card. Unfortunately, you can't just re-check backgroundBehavior and then create a new card. It'll be blank. So, that's when you do what Jacque said about "placing" the group from the object menu. If you created all your cards before creating the background, this is probably the way to go all the time. But, it took me a while to figure that out.

Now here's one other thing. Despite the fact that both text entry fields and label fields are called merely "field" in the property inspector, and both have a locktext property that you can set to true or false, they do not act in the same way when using them in a group as part of background on multiple cards. Let's say you have a group with both both a text entry field and a label field, and you place this group (using either approach above) onto all the cards in your stack. Note the following:

1. Change the text or any other property (backgroundcolor, textsize, name, etc.) in the label field on one card and it will change on all cards with the background. The ID of the field is the same on all the cards, because it's basically the same object just appearing on whatever card you're looking at. However,...

2. Change the text in the text entry field on one card (either directly, or via script), and it won't change the text on the other cards. However, change any other property of the text entry field (backgroundcolor, textsize, name, etc), and it will change on all other cards. This can be useful, but also baffling. Is it really the same field being referenced on all cards, or are they different? Beats me. I can easily get at the different content by using "put field ID 1005 of card 1" or "put field ID 1005 of card 3" but it's strange to me that the same ID number is used . I thought IDs were unique identifiers. Again, can be very useful, but potentially confusing to new folks (and people like me who've been using LiveCode for 5 years).

Mark

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Creating user interface

Post by Simon » Wed Feb 06, 2013 11:23 pm

Hi Mark,
Just on one of your points:
If you want the background on SOME cards, but not others, then you have to uncheck backgroundBehavior when you create the new card (that you want to be blank). You can't selectively delete the background after the fact. If you try to delete on one card, it'll delete on all cards (regardless of whether you uncheck the backgroundbehavior button). You'll get a warning, but once it's gone, it's gone.
When deleting background groups do not use "Delete" but rather from the menubar Object> Remove Group.
You do not have to toggle the backgroundbehavior and only the group on the current card will be removed.
To add the group again Object> Place Group.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

acidjazz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 93
Joined: Mon Feb 16, 2009 2:37 am
Location: Tampa, FL

Re: Creating user interface

Post by acidjazz » Thu Feb 07, 2013 12:06 am

Son of a gun! Thanks!

Mark

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

Re: Creating user interface

Post by jacque » Thu Feb 07, 2013 1:01 am

Right, removing the group as Simon said is the way to go. Deleting a group means destroying the group entirely so that it no longer exists in the stack -- not what you want.

The difference in behavior between label and text fields is just a property setting called the sharedText property, which you can toggle in the field's inspector. The IDE sets the property differently because typically labels have the same text on every card, and usually text fields do not. If sharedText is true, the same text appears on every card that uses the group. If sharedText is false, each card can have its own unique text.

The IDE hides a lot of this, which I don't entirely agree with. The IDE makes it look like there are different types of buttons, different kinds of fields, and so forth. That isn't really true. There is only one button object and one field object. All the different "types" are just a collection of various property settings, which the IDE sets up for you automatically when you drag one from the tool palette. You can easily convert a popup button to any of the others by just changing its properties. But unfortunately the IDE doesn't show all the properties in the inspector; it only shows the ones that are relevant to that particular "type". That reinforces the concept that there are more object types than there really are. You have to set some properties from the message box if you want to turn one type of button into another.

In reality LiveCode has only five objects: button, field, player, image, scrollbar.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

acidjazz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 93
Joined: Mon Feb 16, 2009 2:37 am
Location: Tampa, FL

Re: Creating user interface

Post by acidjazz » Thu Feb 07, 2013 2:47 am

Aha! Very useful information. I always suspected that both fields were, in fact, the same thing but the Sharedtext property eluded me. I did know that buttons were all the same, so probably should have known about fields. Seems embarrassingly obvious in hindsight.

- Mark

Klaus
Posts: 13828
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Creating user interface

Post by Klaus » Thu Feb 07, 2013 12:13 pm

Hi Mark,

all these exiting facts, and even more, can be found in these examples:
http://www.runrev.com/developers/lesson ... nferences/

Not sure, if I mentioned this before 8)


Best

Klaus

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

Re: Creating user interface

Post by jacque » Thu Feb 07, 2013 9:32 pm

Klaus wrote:Hi Mark,

all these exiting facts, and even more, can be found in these examples:
http://www.runrev.com/developers/lesson ... nferences/

Not sure, if I mentioned this before 8)
LOL! Maybe not yet today. :D
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”