SC to RR menu problem

Jeanne A. E. DeVoto jeanne at runrev.com
Mon Oct 14 01:48:01 EDT 2002


At 6:28 AM -0700 10/13/2002, Robert Presender wrote:
>1.     After copying a card, in SC, it is possible to include the name
>of the new card as a menu item(s) into a particular menu and also
>directly include a script for this new menu item(s).
>
>In RR, I am able to create the new menu item(s) into the applicable btn
>menu(of a group of menus) on the new card. I have tried many approaches
>to create a script for the new menu item(s) without success.
>
>I assume that it is not possible to directly set a script for the new
>menu item.  I also assume that the menuPick pWhich routine of the btn
>menu has to be modified to include the case,etc routine for the new
>menu item.
>
>My problem is that I haven't been able to create a script ( in the On
>New routine  in the Main Stack script) to modify the menuPick routine
>or whatever for the new menu item.

Modifying a script is basically like modifying any other property: you put
the property into a variable, make the changes you need, then set the
property back to the variable:

  on newCard
    put the script of button "Cards" into myScript
    -- make changes to myScript
    set the script of button "Cards" to myScript
  end newCard

However, it's a bit awkward to do this if the script is at all complicated,
because you have to do a bit of parsing to find the desired handler, then
add new lines without disrupting the control structures in the handler. In
this case, I would suggest instead writing a general-purpose handler that
can be used regardless of the menu contents:

  on menuPick theItem -- goes in button menu script
    if there is a card theItem then go card theItem
    else beep -- card wasn't there
  end menuPick

This works for all card names, and doesn't require a modification every
time you add a card - it just works off the card name in the menu, so all
you need to do is add the card name to the button's text to have the menu
routine work.

If the menu has menu items other than card names, you can write specific
case structures for those items, for example:

  on menuPick theItem
    switch theItem
    case "Previous"
      go previous card
      break
    case "Next"
      go next card
      break
    default -- if none of the previous cases apply:
      if there is a card theItem then go card theItem
      else beep
    end switch
  end menuPick

In general, you're right that menu items in Rev are not objects - instead,
they're lines in a button - so it's not possible to create a separate
script for a menu item.


>2.  In SC, when a new menu item is created in the copied card's menu,
>the new menu item also appears in the original card's menu.  This
>appears not to happen in RR.  Is a work around necessary to include the
>new item in the original card's menu?

If you mean the same menu bar displayed on more than one card, this should
work - the menubar group is the same object, so changes made on one card
should be reflected everywhere the group is placed. Can you say more about
how you did this, what steps you followed?

--
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