Disabling MenuItems

Rob Cozens rcozens at pon.net
Fri Dec 9 10:53:02 EST 2005


Eric,

>This way of doing eliminates all kind of error and makes completely
>safe your menus handling.

My disableMenuItems & enableMenuItems handlers will be included in 
the next release of Serendipity Library:

on disableMenuItems menuButtonId, itemNumberList
   get the text of button id menuButtonId
   repeat for each item menuItemNumber in itemNumberList
     if char 1 of line menuItemNumber of it <> "(" then put "(" 
before line menuItemNumber of it
   end repeat
   set the text of button id menuButtonId to it
end disableMenuItems

on enableMenuItems menuButtonId, itemNumberList
   get the text of button id menuButtonId
   repeat for each item menuItemNumber in itemNumberList
     if char 1 of line menuItemNumber of it = "(" then delete char 1 
of line menuItemNumber of it
   end repeat
   set the text of button id menuButtonId to it
end enableMenuItems

Since these are meant for gereral purpose use by other developers, it 
cannot be guaranteed that a referenced menuItem is not already in the 
desired state.

BTW, I changed the itemNumberList format from return-delimited lines 
to comma-delimited items, because it's easier to script:

         disableMenuItems 1004,"11,13"

than

         disableMenuItems 1004, "11"&return&"13"

especially when there are many menuItems involved.

With these handlers in Serendipity Library, I can now do all my menu 
setup at preOpenStack.

Rob Cozens CCW
Serendipity Software Company

"And I, which was two fooles, do so grow three;
  Who are a little wise, the best fooles bee."

  from "The Triple Foole" by John Donne (1572-1631) 




More information about the use-livecode mailing list