customdialog.htmlTEXTVIZFb´Ä3´Ä3è Custom Dialogs

Custom Dialogs

Introduction to custom dialogs

Smile supports custom dialogs. Custom dialogs can be saved as files, which can be then opened, either by double-click or by the 'Open' menu or, of course, by script.
Basically, creating a new dialog is accomplished by opening a blank dialog, configuring it with items from the Palette (text fields, buttons etc.), and then adding your own scripting. The toolbox needed is a set of scripts shipped with Smile and are included in the "Development" section of the User scripts . (The below writeups assume that these tools are available)

Custom dialog examples

Smile ships with some dialogs you will find helpful for the functions they provide, and which can serve as examples of what can be accomplished by using the custom dialog capabilities of Smile. These are :
- "Find" dialog, whose file can be found in the "More stuff" folder
- "Preferences" dialog, whose file can be found in the "More stuff" folder
More custom dialogs can be found in the User scripts folder provided with your version of Smile.

Dialog tools at a glance

Align horizontally : aligns multiple selected items in horizontal
Align vertically : aligns multiple selected items in vertical
Fast dialog localization : allows fast setting of the French or US names and strings. Use it after you change the 'language' setting, to localize the dialog.
Geneva 9 : set all dialog items to Geneva 9.
New dialog : opens a new, blank dialog, and opens the palette
Palette : opens a Palette of items to create a custom dialog
Propagate bounds : copies the size of the bounds of the first selected item to the other selected items
Toggle dialog (shortcut  Y) : toggles between "normal" and "edit" modes. See "Dialog mode" below.
The general purpose Duplicate command (shortcut  D) duplicates the selected items.

Creating a custom dialog

New dialog
Choose 'New dialog'. Smile automatically opens new dialogs in "edit" mode. See "Dialog mode" below.
Dialog mode ("normal" & "edit") (shortcut  Y toggles)
Dialog windows (or just "dialogs" for short) have two modes :
"normal" and "edit".
In "edit" mode, an additional inner frame is visible around the dialog window.
Use "normal" when actually using the dialog, and use "edit" when creating or editing the dialog. "Toggle dialog" (shortcut  Y) toggles the active (frontmost) dialog between "edit" and "normal" mode. In "edit" mode the Clipboard functions of the 'Edit' menu are effective on the items of the dialog.
Scripts
Each item of the Palette has an associated script, and the Palette itself also has an associated script. Smile ships with an empty script for each item of the Palette. See "Scripting a dialog" below.

Editing the items of a dialog ("edit" mode)

Double-click any item to open a dialog box which contains fields and checkboxes. The dialog may differ depending on the item opened. The name and contents of the dialog item may be edited. Check ' use script ' if you want to handle a user action in the script. If 'use script' is checked, the script of the container of the item will receive a 'click' event when the user clicks the item. The container of the item can be the dialog, or another item (an item group). See below for more details on these calls. Note that clicking an item never automatically sends any event to its own script.

Scripting a dialog

Editing dialog script ("edit" mode) : use   click to open the dialog's script window . The script of a dialog is a particular case of an object script .
Scripting
To script a dialog, you need to know what calls will be sent to the script of the dialog, and to the scripts of its items (if any), and when these calls occur. Scripting a dialog is writing routines to handle these calls.
Here are the calls :
prepare theDialog is sent to the dialog 'theDialog' when the dialog is opened.
prepare theItem is sent to each dialog item 'theItem' when the parent dialog is opened.
click in theDlogOrItem item number theIndex is sent to the container of a dialog item when the user clicks it, provided the dialog item has its ' use script ' setting checked. The variable 'theDlogOrItem' contains a reference to the container of the dialog item. 'theIndex' is the index of the dialog item.
The event is also sent to the dialog when the user makes a change in an editable text field of the dialog.
idle theDlog is sent to the dialog at idle time, provided its 'want idle' property is set to true (usually, this must be done by script). Dialog items do not automatically receive idle events.
The value returned by the 'idle' handler should be a real number. It is, in seconds, the time after which the 'idle' handler will be called again.

Here is an example of handler for the 'prepare' event :
----------------------------
on prepare theDialog -- in the dialog script
set name of theDialog to "Hello world !"
-- do whatever the dialog initialization requires
end prepare
----------------------------

Of course, dialogs also receive usual events such as drop, do menu, delete, close etc.

Opening a dialog

Like any regular document, dialogs can be opened by double-click, or by choosing 'Open' in the 'File' menu, or by a script. The dialogs which are in the "User Scripts" folder can be opened by selecting their name in the 'Scripts' menu of Smile.
To open a dialog from a file by script, use the following form :
----------------------------
DisplayDlog("", theFile) -- general form
----------------------------
where theFile contains the path name of the file.

¸¸_!ÉReÊ Smile & Akua.3FCIMMManL¡ "Q"´–|H´šÚo"õ"ô!ÉReÊ Smile & Akua.3.1FCOMMManL³ö"X"´šÚk´šé–#².Ï    İk¢  Ÿ  İk¢!  3  İk¢¤  Æ  İk墅    İk¢ƒ  ®  ÔÜ  ì  Ôğ  0  İk¢v    İk¢   q  İk¢u  ¼  İk¢À    İk¢  >  Ôl  |  Ô€  ±  İk¢÷    İk¢&  <  İk¢@  t  İk¢{    İk¢“  Å  İkÂ¢Ì  è  İk墓  u  İk¢|  ˆ  İk¢Œ  µ  İk¢¼  Ê  İk¢Π   İk¢    İk¢   U  İk¢ \  p  İk¢ t  Ï  İk¢ Ö  ç  İk¢ ë  ú  İk¢     İk¢   i  İk¢ m  …  İk¢ ˆ  •  İk¢ ™  °  İk¢ Å  Ê  İk¢ Ñ  ÷  İk¢ =  Y  İk¢ l  z  İk¢ ‚  ê  İk¢ ñ   İk¢   +  İk¢ @  E  İk¢ L  [  İk¢ _  ¡  İk¢ ¥  ¾  İk¢     İk¢   —  İk¢ ¬  ±  İk¢ ¸  k  İk¢r  }  İk¢…  P  İk¢“  ´  İk¢¿  Ò  İkÂ¢Ú  g  İk¢j  r  İk¢v    İk¢‚    İk¢’  À  İkÂ¢à  Ñ  İkÂ¢Õ  X  İkÂ¢š  ±  İk墀  Ş  İk墉  ú  İk¢    İk¢0  5  İk¢<  \  Ô‹  œ  Ô   Ø  Ô    Ô  "  İk¢)  6  İk¢>    İk¢$  <  İk¢C  X  İk¢]    İk¢¤  ·  İk¢¼    İk¢  =  İk¢B  «  İk¢®  ¼  İk¢À  Y  İk¢]  Ì  İkÂ¢Ó  ã  İk墍  Ÿ  İk¢£  9  İk¢A  |  İk¢€     İk¢¤  Ô  İk墯    İk¢  E  İk¢I  X  İk¢\  |  İk¢„  Ş  İk¢$  9  İk¢I  B  İk¢F  Š  İk¢  ®  İk¢²  ß  İk墋    İk¢  <  İk¢`  ~selelist longØlongØpbndlist8longlongGlongšlong¹BDrwfalspvistrueWIDLfalsICFFlongrSiDlong€ptxfTEXTGenevaptpslong Rectlist8longlonglonglongWTBHlongRqULlongLWdtlongBrWdlongAuAdtrueTbSzlong ¸¸_@¸=²ZstylSOUP&reco2€ÿÿ€ÿÿ2‚6Aøcwtx