button.htmlTEXTVIZFD _´Ãè‚´Ãè‚1Ö Buttons

Buttons

Quick start

- To make a new button, use the "Make new button" menu ("Development" section of the user scripts ).
- To open the script of an installed button, click it once with the Command and Option key down (   click).
- To make a button do something, provide a "on mouseUp(theButton)" handler in its script.
- To save a button to disk, pull down its contextual menu and choose 'Save'.
- To install a previously saved button, drop it onto a text window.
- To use a button, click it once. ("Use" means run its 'mouseUp' handler.)
- To get help about a particular button, select the "Help" item of its contextual menu.
- To pull down the contextual menu of a button, press the mouse button with the Control key depressed (Ctrl-click).

Contextual menu

Once a button is installed onto a window, use the contextual menu (Ctrl-click) on the button to reveal its menu. The button's menu includes the following items.
Delete ...
: uninstall the button from the window.
Save as ... : open a dialog box that lets you save the button as a file. A clone of the button can then be installed in any text window by dragging the file's icon onto it.
Help ... : may provide a description of the action of the button - depending on the button's script.
Edit button : open a dialog box which lets you change the aspect and title of the button.

Installing a button

Buttons can only be installed onto text windows (not script windows). To install a ready-made button, drag-and-drop the button onto the window.
A 'Make new button' menu item is available in the "Development" section of the 'Scripts' menu . This menu item will install a new "empty" button in the front window (provided it is a text window).
Buttons are saved when you save the window.
Reminder : Do not get confused. Custom dialog boxes also have buttons (see custom dialogs ), which are different objects.

Scripting a button

Each button includes in its object script a 'mouseUp' handler that will run when the button is clicked (assuming that the button is installed onto a window). To open the script, use   click on the button (like in Hypercard).
You may want to write two handlers in the script of a button, 'helpString' and 'mouseUp'.
helpString : this handler is optional. It must return a short string (< 255 characters long) which will be displayed in a dialog box when the user selects the 'Help' item of the contextual menu of the button. For a multilingual help, test the global variable 'my language code' - 0 for US English and 1 for French.
mouseUp : contains the action associated with clicking the button.

----------------------------
on helpString(theButton)
-- make and return a short help string
end helpString
----------------------------

----------------------------
on mouseUp(theButton)
-- do the action
end mouseUp
----------------------------

Both handlers have one parameter, a reference to the button. Use the 'container' property to refer to the window containing the button.

 _tax for using text-to-speech and speech recognition from within AS, as well as a PDF of some pages off of Apple's site, including the one on phonemes. That page is available on the Web at