highlight a button in standalone+.rev app

Richard Gaskin ambassador at fourthworld.com
Fri Jul 1 06:21:17 EDT 2005


rev at armbase.com wrote:
> I'd like to have just one button injector and a system to customise the function
> of the button. What I envisage is a drop down list that enters a script into the
> button.

Have you considered using a custom property instead?

For example, one way to assign behaviors to objects is the define the 
behavior in a frontScript, triggered by the actions you want to respond 
to.  A custom property in the target determines whether the custom 
behavior is invoked, or the message is simply passed.

For your buttons:

   set the uAction of btn 1 to "AutoBehavior"


In your frontScript:

   on mouseUp
     if the uAction of the target = "AutoBehavior" then
         DoAutoBehavior --< your stuff here
     else pass mouseUp
   end mouseUp


If you want different actions you can add lots of options without making 
it unreadable with a switch block rather than nested IFs:

   on mouseUp
      switch the uAction of the target
      case "AutoBehavior"
         DoAutoBehavior
         break
      --
      case "AnotherBehavior"
         DoAnotherBehavior
         break
      --
      default
        pass mouseUp
      end switch
   end mouseUp




As for the name of an unknown stack, usually topStack() will return what 
you need. Here are the notes from the Transcript Dictionary entry for 
the topStack function:

   In most applications, the active window holds the current
   document, and menu commands operate on the active window.
   In Revolution, because of the ability to open stacks in
   various modes, this is not necessarily the case.

   Each open window has a mode associated with it. The
   topStack is the frontmost stack with the lowest mode.

   For example, an editable window has a mode of 1, and a
   palette has a mode of 4. If several palettes and editable
   windows are open, the topStack is the frontmost editable
   stack, although palettes may be in front of it. If all
   the editable windows are then closed, the frontmost
   palette becomes the topStack, since there is now no
   window with a lower mode.



--
  Richard Gaskin
  Managing Editor, revJournal
  _______________________________________________________
  Rev tips, tutorials and more: http://www.revJournal.com



More information about the use-livecode mailing list