Accessibility

TechNote (Archived)

Making Pop-up Menus or Drop-down Lists with Lingo

Creating menus
The following sample Lingo Script illustrates how a Windows "drop-down" list or Macintosh "pop-up menu" can be created. The example allows the end user to choose a college major from a text field.

Sample Lingo script
This is a Cast Script for the field whose content starts out as "Majors". It handles rolloffs, guards against flickering, and leaves the chosen major in the field (or, if the user rolls off the field, displays "Majors" at the end):

 on mouseDown     set me = the castNum of sprite (the clickOn)     --  Prep the dropdown list:     set dropList = ["world lit", "politics", "basketry", "football", "grant writing"]     set temp = EMPTY     repeat with x in dropList         put x & RETURN after temp     end repeat     --  Remove the trailing "RETURN":     delete char (length (temp)) of temp     put temp into field me     --  Enter main repeat loop:     set oldLine = 0     repeat while the stilldown         if the mouseCast = me then set newLine = the mouseLine               else set newLine = 0         if oldLine <> newLine then             if newLine then hilite line (newLine) of field me             else put temp into field me             set oldLine = newLine         end if     end repeat     --  Clean up and close out:     if newLine then put (line (newLine) of field me) into field me     else put "Majors" into field me end mouseDown 

Additional information explaining the script:

A list is used in the "prep" section because it is easy to edit or set the "temp" variable literally.

Trailing spaces can be added to each entry if the highlight is to be applied to the entire line rather than to just the text.

The"oldLine/newLine" section of the Lingo guards against flicker: a line is only highlighted if there's a change in the line that the mouse is above.
"Put temp into field me" will remove any existing highlight, and occurs if the end user rolls off the field.

In the "cleanup" section retrieve the chosen string later by querying the contents of the field.



AlertThis content requires Flash

To view this content, JavaScript must be enabled, and you need the latest version of the Adobe Flash Player.

Download the free Flash Player now!

Get Adobe Flash Player

Creative Commons License

Search Support

Document Details

ID:tn_3160

Products Affected: