Creating a Font menu

Jeanne A. E. DeVoto jeanne at runrev.com
Sat Apr 27 20:28:26 EDT 2002


At 8:14 AM -0700 4/27/2002, Dave wrote:
>Now, how do you wire those menu items to actually do something?  Do you have
>to dynamically create a huge script for that menu?

Here's one example (this is for a simple Font menu):

  on menuPick theMenuItem
    -- the menuPick message is sent to the menu button
    -- when the user chooses a menu item
    set the textFont of the selectedChunk to theMenuItem
  end menuPick

>Is there any kind of function that will determine what menu item you are
>coming from?  Let's say I have a text menu that displays font, size and
>style.  If I select a particular font in the font menu can I determine I'm
>coming from the font menu are not some other?  If so, I could trap for that
>menu item and create a much smaller routine to handle just fonts.

If you're working with submenus, the levels of items are separated with a
vertical bar |. For example, if your menu has a "Font" submenu from which
you choose "Times", the parameter to the menuPick messsage is "Font|Times".

Here's a code example:

  on menuPick theMenuItem
    set the itemDelimiter to "|" - so we can easily separate the parts
    switch item 1 of theMenuItem
    case "Font"
       set the textFont of the selectedChunk to item 2 of theMenuItem
       break
    end switch
  end menuPick

--
Jeanne A. E. DeVoto ~ jeanne at runrev.com
Runtime Revolution Limited - The Solution for Software Development
http://www.runrev.com/





More information about the use-livecode mailing list