Menu item addition/runtime

Jeanne A. E. DeVoto jeanne at runrev.com
Sun Feb 10 19:47:06 EST 2002


At 3:54 PM -0800 2/10/2002, Robert Presender wrote:
> 1. create a menu btn with several items (includes menuPick
> switch scripts) - no problem, can do
> 2. create new card  by copy/paste routine of a basic card of
> a particular stack - no problem, can do
> **3. insert the name of the new card as a new item(after the
> initial items) to the menu of 1. above by script.
>      Need help here .. . can't find an applicable Transscript ...

Try this:

  put return & the short name of this card \
     after the text of button "Menu Name"
  -- use whatever you want as "New Item", of course - can be
  -- "the short name of this card", or a variable, or whatever

> **4. add a menuPick switch script (to existing script) for
> the new item of 3. above.

You can pull the script into a variable, change the variable, and set the
script property back to the variable (as in SuperCard).

However, if the script is at all long, you'll run into the Starter Kit
limit in setting and compiling the script, so this method isn't ideal.

Can you use a more general menuPick handler that will work no matter what
you add to the menu? For example:

  on menuPick theItem
    switch theItem
    case "Do Something"
      -- some code here for the first menu item
      break
    case "Something Else"
      -- code for the second menu item
      break
    default -- code for all dynamically added menu items
      go card theItem -- or whatever you want to do
    end switch
  end menuPick

This would let your menu react to the added menu items, without having to
add a case for each specific item.

--
Jeanne A. E. DeVoto ~ jeanne at runrev.com
http://www.runrev.com/
Runtime Revolution Limited - Power to the Developer!





More information about the use-livecode mailing list