Humanities Home page   Office of Digital Humanities
Back     BYU LiveCode Lessons Gateway

DigHT 310
Scripting Everything

A Totally Scriptable Architecture

LiveCode was built on the principle that virtually anything that can be done through the user interface--the menus, property palettes, and other tools--can be accomplished through scripting. For instance, instead of using the Tools Palette to create a new button, you can simply enter this command in the message box:

create button "myButton"

A button with the name indicated will be created on the current card. You may be thinking, "But it's faster to just point and click to create objects." And you may be right. However, the implication of this ability to do anything via scripting is that you can write scripts that will automatically modify your stack under whatever conditions you stipulate. For example, you might want to script the creation of new cards for each new question in a quiz, and then have a script that deletes these cards when the quiz is over. This ability to script the way your stacks look and behave gives you as the developer total control over everything that happens in your stack.

Scripting for Color

As an example of the scriptable architecture let's look at the color properties of objects in LiveCode. For example, you might want to change the background color of a field if certain conditions apply. You could script the change by changing the backgroundColor property of the field, like this:

set the backgroundColor of fld "fancyField" to colorReference

A color reference can have one of three forms:

Here is a list of LiveCode terms that affect color:

TERM TYPE Synonyms Description

accentColor

property

 

The accentColor property specifies the highlight color used for the active menu item.

answer color

command

  The answer color command displays the operating system's standard color-selection dialog box.

backgroundColor

property

backColor, secondColor, fillBack The backgroundColor property specifies an object's background color.

borderColor

property

fourthColor, markerFillColor The borderColor property specifies the color of an object's border.

bottomColor

property

sixthColor The bottomColor property specifies the color of a three-D object's lowered edge.

brushColor

property

  The brushColor property specifies the color used to paint and to fill shapes in an image.

colorMap

property

  The colorMap property lists the colors in the current color table.

colorNames

function

  The colorNames function returns a list of the color names you can use in LiveCode.

colors

property

  The colors property specifies all the colors of an object, in shorthand form.

colorWorld

property

  The colorWorld property reports whether the screen is set to use color.

focusColor

property

eighthColor The focusColor property specifies the color of the outline around the active control or the field with the insertion point.

foregroundColor

property

foreColor, firstColor, textColor, thumbColor, fillFore, penFore The foregroundColor property specifies the color of object text and borders.

hiliteColor

property

markerColor, thirdColor The hiliteColor property specifies the color of the background when an object, or text in an object, is highlighted.

linkColor

property

  The linkColor property specifies the color of grouped text.

linkHiliteColor

property

  The linkHiliteColor property specifies the color of grouped text that is being clicked.

linkVisitedColor

property

  The linkVisitedColor property specifies the color of grouped text that has been clicked during the current session.

lock colorMap

command

  The lock colorMap command sets the lockColorMap property to true, preventing the screen from being redrawn when the color table is changed.

lockColorMap

property

  The lockColormap property specifies whether changes to the color table cause the screen to be redrawn with the new color table.

mouseColor

property

  The mouseColor function returns the color of the pixel that the mouse pointer is over.

penColor

property

  The penColor property specifies the color used for drawing with the paint tools.

printColors

property

  The printColors property specifies whether objects are printed in color or black and white.

privateColors

property

  The privateColors property specifies whether LiveCode uses its own color table or the system color table on Unix systems.

remapColor

property

  The remapColor property has no effect, and is included in LiveCode for compatibility with imported SuperCard projects.

screenColors

function

  The screenColors function returns the number of colors the screen can display.

selectionHandleColor

property

  The selectionHandlerColor property specifies the color of the handle boxes used to resize a selected object.

shadowColor

property

seventhColor The shadowColor property specifies the color of an object's drop shadow or the background of a scrollbar.

systemColorSelector

property

  The systemColorSelector property is not implemented and is reserved.

topColor

property

fifthColor The topColor property specifies the color of a three-D object's raised edge.

unlock colorMap

command

  The unlock colorMap command sets the lockColorMap property to false, causing the screen to be redrawn with the new color table every time the color table is changed.

Related Scripting Elements

There are other elements of LiveCode that don't deal directly with color, but are related. In particular, there is a whole set of properties that specify patterns that are used in various parts of objects. Here are some other interesting elements:

TERM

TYPE

Synonyms Description

blend

keyword

 

The blend keyword specifies one of the transfer modes that can be used with the ink property.

blendLevel

property

  The blendLevel property specifies the degree of transparency of an image whose ink property is set to “blend”.

ink

property

  The ink property specifies the kind of transparency an object is drawn with.

In-Class Exercise: Scripting Everything


Back     BYU LiveCode Lessons Gateway
Maintained by Devin Asay.
Copyright © 2005 Brigham Young University