news |
info |
people |
software |
stuff |
SamsPalette XCMD. Version 2.2d4, by Sam Deane. Copyright ©1994 ULTRALAB. Compiled 14:46:40, 02/12/94. Debugging code included.
These include:
+ mixed sticky and clicky buttons
+ everything changable under script control
+ palettes loaded from resources or created from scratch using hypertalk commands
+ Êhelp balloons for each button
+ Êuser defined messages for move,close,within,idle
+ optional mono and colour versions of a picture, chosen on the fly to suit the screen
First, of course, you need a palette window to work with. You can either create a new palette window or retrieve an old one from a resource. The syntax for this is as follows:
SamsPalette "create",<name> {,<WDEF id> {,<WDEF variation> }}
The <name> parameter is the name of the palette that you want to use or create. If an SPLT resource with that name is found (see below for an explanation of these resources), then it is used to define the palette. If not, a new empty palette is created.
A new palette is initially hidden, with no buttons, no picture, and all other properties set to default values.
The <WDEF id> and <WDEF variation> parameters are both optional. They specify the id and variation code of a WDEF resource, which will be used to draw the palette, instead of the hypercard'sstandard windoid WDEF.
Increasing the value of the property will create new buttons, but until their position and behaviour have been properly specified (see the current and data properties below), they will in an undefined state.
If the value of the property is decreased, any buttons over the new limit will not be destroyed, but simply disabled.
Æ NB: The current version of this XCMD limits the number of buttons allowed to 32. This restriction will be removed in a future version.
on mouseUp if GotTest() then set current of window "test" to 1 ask "AutoHilite of button 1?" with the buttonHilite of window "test" if it empty then set buttonHilite of window "test" to it end if end if end mouseUp
First, to indicate which button you are going to work on, you must set the current property of a palette.
The various properties of the current button can now be inspected or set using a number of other properties: buttonDown, buttonUp, buttonRect, etc...
It has been superceded by the buttonDown, buttonUp, buttonRect etc properties.
Getting the property will return the name or id of the PICT resource that is currently being displayed. The picture can be changed at any time, by setting the property to the name or id of a new resource.
on mouseUp if GotTest() then get the pict of window "test" if it is "test" then set the pict of window "test" to "test 2" else set the pict of window "test" to "test" end if end if end mouseUp
on mouseUp if GotTest() then ask "Rect of window?" with the rect of window "test" if it empty then set the rect of window "Test" to it end if end if end mouseUp
on mouseUp if GotTest() then ask "Cursor?" with the cursor of window "test" if it empty then set cursor of window "test" to it end if end if end mouseUp
First, to indicate which button you are going to work on, you must set the current property of a palette.
The various properties of the current button can now be inspected or set using a number of other propert The data property can then be used to get or set the data for the current button.
The data for each button has the following format:
message,sticky,hilite,icon,help,rect
where:
messageis the message that the button should send to the card when clicked. It should be a short HyperTalk expression, without any commas in it. Typically this is the name of a hypercard handler defined somewhere else.
stickyis a boolean flag saying whether the button stays selected after it has been clicked on.
hiliteis a boolean flag saying whether the button is currently hilited.
iconis unused at the moment. It should be set to 0. This property will be supported in a future version.
rectis the rectangle of the button, relative to the top-left corner of the palette.
helpis the name of a TEXT resource (or TEXT and styl resource pair) containing a baloon help message for the button. When balloon help is switched on, the text in this resource will be displayed when the mouse is over the button.
Here is a script to set the first button in a three button palette so that it beeps when clicked on, it is not sticky, it is unhilited, and it is positioned at 16,16,32,32.
-- set palette to have three buttons
set the buttons of window "example" to 3
-- set up the button data for button 1
put "beep,false,false,0,button 1 help,16,16,32,32" into bdata
--- set up button 1
set the current of window "example" to 1
set the data of window "example" to bdata
on mouseUp if GotTest() then set current of window "test" to 1 ask "buttonDown of button 1?" with the buttonDown of window "test" if it empty then set buttonDown of window "test" to it end if end if end mouseUp
on mouseUp if GotTest() then set current of window "test" to 1 ask "buttonUp of button 1?" with the buttonUp of window "test" if it empty then set buttonUp of window "test" to it end if end if end mouseUp
on mouseUp if GotTest() then set current of window "test" to 1 ask "buttonRect of button 1?" with the buttonRect of window "test" if it empty then set buttonRect of window "test" to it end if end if end mouseUp
on mouseUp if GotTest() then set current of window "test" to 1 ask "buttonHilite of button 1?" with the buttonHilite of window "test" if it empty then set buttonHilite of window "test" to it end if end if end mouseUp
on mouseUp if GotTest() then set current of window "test" to 1 ask "buttonSticky of button 1?" with the buttonSticky of window "test" if it empty then set buttonSticky of window "test" to it end if end if end mouseUp
on mouseUp if GotTest() then set current of window "test" to 1 ask "buttonHelp of button 1?" with the buttonHelp of window "test" if it empty then set buttonHelp of window "test" to it end if end if end mouseUp
on mouseUp if GotTest() then ask "Rect of window?" with the globalRect of window "test" if it empty then set the globalRect of window "Test" to it end if end if end mouseUp
on mouseUp if GotTest() then set current of window "test" to 1 ask "buttonEnabled of button 1?" with the buttonEnabled of window "test" if it empty then set buttonEnabled of window "test" to it end if end if end mouseUp
on mouseUp if GotTest() then set current of window "test" to 1 ask "buttonKind of button 1?" with the buttonKind of window "test" if it empty then set buttonKind of window "test" to it end if end if end mouseUp
on mouseUp if GotTest() then ask "Keep back?" with the keepBack of window "test" if it empty then set keepBack of window "test" to it end if end if end mouseUp
on mouseUp if GotTest() then send save to window "Test" end if end mouseUp