news |
info |
people |
software |
stuff |
Poppet XFCN. Version 1.1d3, by Sam Deane. Copyright ©1994 ULTRALAB. Compiled 15:42:06, 12/12/94. Debugging code included.
Before Hypercard 2.2, there was no built in way to display popups. With the advent of the 2.2 pop-up button style, this is no longer the case. However, I still find that there are situations where I would prefer to use this XFCN - for example when I don't know that my users will have 2.2!
The characters are:
; orreturn seperates items ^ gives the item an icon: if c is the next character after the ^, then the icon's id is: charToNum(c) - 48 + 256 ! the next character is the mark character <B sets the item's style to bold <I sets the item's style to italic <U sets the item's style to underline <O sets the item's style to outline <S sets the item's style to shadow / next character after the / is the keyboard equivalent ( disables the item (- makes the item a seperator line
on mouseDown get Poppet(resource,"test menu",1,the loc of the target) end mouseDown
The syntax is:
Poppet("items",<items>,<default>,<loc> {,<delimiter>})
The <items> parameter contains the menu items for the popup. By default, the XFCN expects these items to be delimited by a semi-colon, or a return. If you want to use a different delimiter (a comma for example), you can use the <delimiter> parameter to tell the XFCN about it. Some characters in each of the items are interpreted in special ways, allowing you to set an item's font, style, command key, etc: see "Special Characters" for more details.
The <default> parameter tells the XFCN which of the items in the menu should be hilited to start with.
The <loc> parameter positions the pop-up menu, by giving the location of the top left hand corner of the default item.
When the XFCN is called, it displays the menu and waits whilst the user makes a choice. When the mouse button is released, the XFCN returns a result, consisting of three items:
<number>,<menu>,<name>
The <number> part gives the item number of the selected item, or 0 if no item was selected.
The <name> part gives the actual text of the selected item.
The <menu> part is only relevant for the resource command.
on mouseDown put "/1!×one,/2!¥type
This command is used to display a pop-up menu containing the names of every available resource of a certain type - for example a font menu.The syntax is:
Poppet("type",<type>,<default>,<loc>)
The <type> parameter should be a four letter resource type, for example FONT for a font menu.
The <default> parameter tells the XFCN which of the items in the menu should be hilited to start with.
The <loc> parameter positions the pop-up menu, by giving the location of the top left hand corner of the default item.
When the XFCN is called, it displays the menu and waits whilst the user makes a choice. When the mouse button is released, the XFCN returns a result, consisting of three items:
<number>,<menu>,<name>The <number> part gives the item number of the selected item, or 0 if no item was selected.
The <name> part gives the actual text of the selected item.
The <menu> is only relevant for the resource command.
Example script for type
on mouseDown put Poppet(type,"FONT",1,the loc of the target) end mouseDownresource
This command is used to display a pop-up menu from a MENU resource. If the contents of a menu is always going to be the same, storing it as a MENU resource offers a number of advantages. MENU resources allow a finer degree of control over the appearance of their menu items; they are faster to display; they are easier for someone else to translate; they allow you to build hierarchical menus.The syntax is:
Poppet("resource",<name>,<default>,<loc>)
The <name> parameter should be the name or id of a MENU resource stored in the stack. MENU resources can be created and edited with resource editing programs, such as ResEdit or Rez.
The <default> parameter tells the XFCN which of the items in the menu should be hilited to start with.
The <loc> parameter positions the pop-up menu, by giving the location of the top left hand corner of the default item.
When the XFCN is called, it displays the menu and waits whilst the user makes a choice. When the mouse button is released, the XFCN returns a result, consisting of three items:
<number>,<menu>,<name>The <number> part gives the item number of the selected item, or 0 if no item was selected.
The <name> part gives the actual text of the selected item.
The <menu> part gives the name of the menu in which the selected item was. This is needed for hierarchical menus, to distinguish items from different sub-menus.
Example script for resource
on mouseDown put Poppet(resource,"test menu",1,the loc of the target) end mouseDownsaveItems
not yet documented!plain
This command works just like the items command, except that any special characters in the menu items are ignored, so the style of all of the menu items will be plain. This is useful if you want to display menu items which include one or more of the special characters.The syntax is:
Poppet("plain",<items>,<default>,<loc> {,<delimiter>})
The <items> parameter contains the menu items for the popup. By default, the XFCN expects these items to be delimited by a semi-colon, or a return. If you want to use a different delimiter (a comma for example), you can use the <delimiter> parameter to tell the XFCN about it.
The <default> parameter tells the XFCN which of the items in the menu should be hilited to start with.
The <loc> parameter positions the pop-up menu, by giving the location of the top left hand corner of the default item.
When the XFCN is called, it displays the menu and waits whilst the user makes a choice. When the mouse button is released, the XFCN returns a result, consisting of three items:
<number>,<menu>,<name>The <number> part gives the item number of the selected item, or 0 if no item was selected.
The <name> part gives the actual text of the selected item.
The <menu> part is only relevant for the resource command.
Example script for plain
on mouseDown put "/1!×one,/2!¥