Enabling/Disabling MenuItems in LC

Terence Heaford t.heaford at icloud.com
Sun Apr 26 14:23:08 EDT 2015


I have implemented the following script in the menubar to enable/disable menuItems.

Is this the normal way of doing this or is there another way as I am getting strange behaviour.

The shortcut keys I have set do not work for these items.

menuItem 3 of menu "File" — close
menuItem 1 of menu "Actions" — Categories
menuItem 2 of menu "Actions" — Find
	

--------------------------
on mouseDown tMenu
   if tMenu = 1 and the uDBOpen of stack  “TH" is true then
      setMenusOpen
   else
      setMenusClosed
   end if
end mouseDown

on setMenusOpen
   set the lockmenus to true
   
   disable menuItem 1 of menu "File" -- new
   disable menuItem 2 of menu "File" -- open
   enable menuItem 3 of menu "File" -- close
   enable menuItem 5 of menu "File" -- import
   enable menuItem 6 of menu "File" -- export
   enable menuItem 7 of menu "File" -- print
   
   enable menuItem 1 of menu "Actions" -- Categories
   enable menuItem 2 of menu "Actions" -- Find
   
   set the lockmenus to false
end setMenusOpen

on setMenusClosed
   set the lockmenus to true
   enable menuItem 1 of menu "File"
   enable menuItem 2 of menu "File"
   disable menuItem 3 of menu "File"
   disable menuItem 5 of menu "File"
   disable menuItem 6 of menu "File"
   disable menuItem 7 of menu "File"
   
   disable menuItem 1 of menu "Actions"
   disable menuItem 2 of menu "Actions"
   set the lockmenus to false
end setMenusClosed


More information about the Use-livecode mailing list