By the end of this lesson you should:
As mentioned in the previous lecture, objects are the basic building blocks in the LiveCode authoring environment. There are several different types of objects: stacks, cards, buttons, fields, graphics, etc. Apart from being fundamentally dissimilar, they also have characteristic variances within object types. Just like Lego blocks, these objects all come in different shapes, sizes, and colors. In LiveCode, these characteristics are called properties.
All objects in LiveCode have properties or distinct characteristics that determine how they appear and behave. As with Legos the objects can be very generic or very specialized, all depending upon what the specific properties of the object are.
You can access an object’s properties easily by double-clicking on the desired object with the pointer tool while in edit mode, or by selecting the appropriate inspector under the Object menu. This will cause the properties of the particular object to be displayed in the Property Inspector palette.
Once the Property Inspector is visible, each time a different object is selected with the pointer tool (or with the selector option in the top right of the inspector palette), the inspector changes to display the properties for that object. Let’s look first at properties common to all objects, and then move into important properties that are unique to various objects.
The Basic Properties Pane
You should be aware that most objects share several common, basic properties. Several of these common properties are found in the Basic Properties pane of the property inspector. Some of the other common properties are found in other sections of the property inspector.
Property Inspector Sections
The properties for each object have been organized into different sections. At the top of the inspector is a menu through which one can jump between sections. By default the Basic Properties is selected the first time the inspector is opened (as displayed above). The different sections available depend upon the type of object selected.
Size & Position
In the Size & Position pane of the property inspector we find the following common properties, which pertain to almost all LiveCode objects:
In LiveCode all objects can have a blend or transparency level.
There are a few other common properties, which will be addressed in Inheritance section below.
If you watch the Property Inspector window as you select different objects, you will see that the properties displayed change according to the type of object selected, sometimes quite drastically. For now we will cover only certain commonly used properties. Some properties are more or less self-explanatory and will not be covered in depth here. The best way to learn about properties is by exploring property inspectors for objects on your own in LiveCode. That said, let’s look at a few properties that are unique to the various object types, and which are important to know about.
A few stack properties you should be aware of:
- Basic Properties: Title. Give every stack you make a meaningful Title. This is the text displayed in the title bar of your stack. If you do not, it displays the file name you have assigned the stack with an asterisk reminding you that you have not given it a title. In other words, it looks unprofessional to leave it titleless.
- Size & Position: Resizable. This is checked by default, allowing you to grab the lower right corner and change the dimensions of the stack (the cards assume the same size as the stack). Once you have the desired dimensions for your stack, it is best to uncheck this box as to not allow the user to alter the appearance of your stack.
One unique card property that you should know about:
- Basic Properties: Number. Here you can alter the order in which the cards are organized. Changing the number here changes the placement of the card in relation to the other cards in the stack.
Groups are a unique object type and will be covered in a later lecture. There is one property that is fundamentally important to how a group behaves. We’ll mention it here but discuss it in detail later.
- Basic Properties: Behave like a background. When this property is checked a group (and the objects in it) can appear on more than one card. This ability is unique to groups and has important implications for how stacks can be designed.
Since buttons are one of the most commonly-used control objects, there are a few properties with which we need to be familiar:
- Basic Properties: Label. Any text placed here will be displayed by the button. If left blank, the button’s name is shown instead. This all hinges upon whether the Show name property is checked or not.
- Basic Properties: Tool tip. Any text placed here will be displayed as a type of help when the user hovers the mouse over the object.
- Icons & Border: Icon. Here you can assign the button an image as an icon to give a visual cue as to its function. You can assign icons with slightly different appearances to indicate normal, hilited, disabled, and “hover” states for the button.
Fields are another control object we will use quite frequently.
- Basic Properties: Don’t wrap. By default all text typed in a field will automatically wrap to the next line when the end of the field is reached (i.e., it will insert soft returns). Checking this will cause all text to be confined to one line unless interrupted by a hard return.
- Basic Properties: Lock text. By default a field is not locked and a person can enter text into it (as evidenced by the mouse cursor changing to an “i-beam” when the mouse is positioned over the field). When checked the user cannot type in the field, i.e., they cannot alter whatever you may have put in that field, so if you are using a field to display information that you don’t want the user to change, make sure you lock that field.
- Basic Properties: Focusable. Enables a user to tab into the field for editing, if the field is not locked. If the text is locked the user can select text and scroll within the field if this box is checked. If not checked, a user cannot type or select text.
- Basic Properties: Scrollbars H/V. Selecting either one of these will give the field a scrollbar that allows the user to scroll through the information in the field.
- Contents. The field at the bottom of the palette displays the text in the field. Text may be added/edited here (even if the field is locked).
- Table: Text baselines. Checking this option will give the field the appearance of lined paper.
- Table: Tab stops. Providing a value here will allow one to set tab stops using the tab key. The number given is the stop position in number of pixels from the left edge of the field.
The available properties change depending upon the type of graphic object. All of them have to do with physical attributes of the graphic and allow you to change those properties manually here.
- Basic Properties: Type. Allows one to alter the type of graphic without creating a new one.
- Basic Properties: Antialiased. When checked, smoothes out the “jaggy” appearance of curved and angled lines by filling the jags with lighter colored pixels of the same hue.
- Basic Properties: Size (more accurately lineSize). This number determines the thickness, in pixels, of the line that describes the shape of the graphic.
There is an object hierarchy in LiveCode through which properties settings are passed or “inherited,” much like physical characteristics and personality traits within a biological family. Properties for a particular object are “inherited” from another object higher in the hierarchy. It may be viewed in terms of ownership: Stacks contain and therefore own cards and groups, which in turn contain and own control objects such as buttons, fields, images, etc. In biological terms, stacks are grandparents, cards and groups are parents, and buttons and fields are the children. Properties are passed or inherited through that hierarchy. Consequently, if a stack has a particular property value, then all objects owned by that stack inherit the same property value. Changing that particular characteristic subsequently changes the property for all objects below that object in the hierarchy (here the biological metaphor breaks down). Property values are passed only down the hierarchy. They never move up, nor do they affect objects that exist together on the same card.
There are a few inherited properties whose effects are obviously noticeable:
The Colors & Patterns pane of an object’s property inspector show the the several color properties that can be set for the object. When these properties are not set for an object they are determined by inheritance from parent objects. There are many colors that may be chosen for any given object, and there are several different aspects of the object you can select colors for. The most common properties you might want to change for an object are be the Text (foreground) and the Fill (background). For most objects the text color determines the color of the text being displayed by the object, or the color of the stroke or outline of the object. The fill color, of course, indicates the interior color of the object itself. There are variations between objects and within object types, which you will readily see as you experiment with color settings. Once a color has been set for an object, you can click the Clear button to reset the color value to what the object had inherited through the object hierarchy.
As the name of this pane implies, you can also choose patterns to fill the background or other color areas of the object.
These properties determine how the text for the object is displayed (e.g., font, size, alignment within the object, etc.) The margins surrounding that text can also be changed. As mentioned before, when these properties are altered for stack, card, and group objects, these settings also are applied to all child objects in their hierarchies, assuming those properties have not been set for the child objects.
As hinted at previously, there are so many other properties that we cannot adequately cover them here without causing you drastic overload. Please take the time to experiment with the various objects and determine how these and other properties alter the appearance and function of the various objects.Object/Property Exercise, Part 2