The Tools Palette - Objects (Controls), Tools and MessagesIt is very simple to create an application in LiveCode, by dragging objects onto your stack from the Tools Palette and adding code for the messages you want to respond to you can create a simple application in minutes. This section will cover the basic controls and the most common messages associated with them. These terms are new and may be confusing for the novice. In short: - Objects - In object-oriented languages, everything is considered objects
- Controls - the newer and more general term for referring to objects since they can be objects, groups of objects or just control other objects. You will see the terms used interchangibly but Controls is the newer and more proper term to use
- Messages - objects send messages to each other. A mouse send "mouseDown", "mouseUp", "doubleClick" and other messages to other objects (your program). You then can write "message handlers" with code to perform an action when that message is received. (Java recently adopted these terms)
The Tools PaletteDrag objects such as buttons, fields, scrollbars and graphics from the Tools Palette onto your stack.
Once you have added objects to your stack, choose Edit mode to move, resize and change the properties of objects.
The Tools Palette allows you to switch between Edit mode, for adding objects, making changes, coding, and Run mode, for interacting with your application.
Controls
This is the Standard Tools Palette (versions: 5,6,7) The Widgets Section (added in vers 8, 9)
 This is the Tools Palette (versions: 8, 9 of LiveCode - with "widgets" added)
It has 4 discrete sections:
Widget Controls Classic Controls Graphic Tools Paint Tools
We will now look at each section and it's tools:
1. The Run/Edit Controls (at the very top) - Very Important
Run and Edit Mode
These are the most important tools. They allow you to switch between editing your program and running it. Actually, it is running while you are editing. So you can change code and immediately see what happens. (Thus the name "LiveCode")
Run mode: When in run mode, objects receive all the normal messages that drive a LiveCode application. For example, clicking on a button in run mode will cause a mouseUp message to be sent to it and the script will run.
Edit mode: When in edit mode, objects do not receive messages when you click on them, and you can move, resize or edit the properties for objects.
2. Widget Controls
3. Classic Controls
- Buttons There are 6 types of button in the Tools Palette. All these buttons are fundamentally the same but have different default property sets.
 Common messages associated with buttons
- mouseUp: Sent when the user releases the mouse button. Handle the mouseUp message to perform an action when the user releases the mouse button after clicking.
- mouseDown: Sent when the user holds the button down (when doing drag-and-drop operations)
- Fields
There are 5 types of field in the Tools Palette. All these fields are fundamentally the same but have different default property sets.
 Common messages associated with fields
- openField: Sent to an unlocked field when you click or select text in that field. Handle the openField message if you want to do something when the user enters a field.
- closeField: Sent to a field when the focus is being removed from that field and the field’s content has changed. Handle the closeField message if you want to make sure a field’s content is correct after it has been changed.
- textChanged: Sent when the content of a field has changed. Handle the textChanged message if you want to perform an action when the content of a field changes.
The DataGrid also appears in this section of the Tools Palette. The DataGrid object allows you to use complex tables and forms into your application.
- Menus
There are 4 types of menu in the Tools Palette, menus are buttons with certain properties set that make them behave as menus.
 Common messages associated with menus
- menuPick: Sent to a button when a menu item is chosen from the menu associated with that button. Handle the menuPick message to do something when the user chooses a menu item from a button menu, or chooses a tab in a tabbed button.
- Scrollbars
There are 4 types of scrollbar in the Tools Palette, all these scrollabars are fundamentally the same but have different default property sets.
 Common messages associated with scrollbars
- scrollbarDrag: Sent to a field, scrollbar, or group when the user drags the scrollbar thumb or when a text selection causes a field to scroll. Handle the scrollbarDrag message if you want to respond to the user dragging the scrollbar thumb.
- Images
An image object is a control that contains a bitmapped picture. Use the image object type to hold photographs, icons, and decorative elements, and to allow the user to paint.
 You can set the filename property of an image to display an image stored in a separate file.
- Players
A player object is a control that displays a movie or sound file. Set the filename property of a player to display a movie or sound from a separate file.
 Common messages associated with players
- playStarted: Sent to a player when it starts playing. Handle the playStarted message if you want to perform a task when a movie or sound starts playing.
- playPaused: Sent to a player when the user pauses it. Handle the playPaused message if you want to perform an update when a player is paused.
- playStopped: Sent to a player when it stops playing. Handle the playStopped message if you want to perform a task when a movie or sound finishes playing.
4. Graphic Objects and Tools
Graphics
The Tools Palette allows you to choose from a selection of shapes when creating a new graphic.
 Use the fill bucket to choose the fill color, the fill pencil to choose the line color, the line thickness menu to choose the line thickness, and the optional shape menu to choose preferences specific to the type of graphic selected.
|
|