command.menuΒΆ

nil command.menu ( string label , string icon , string shortcut )

Create a menu

This function creates a new menu. A menu is a special kind of command that contains children commands. The main menu is MainMenu. Menus have methods:

  • menu:findcommand (label) : look for a child command by its label
  • menu:addseparator (menuLabel, [submenuLabel, ... , itemLabel]) : add a separator after the item or at the end of the specified sub menu.
  • menu:addcommand (command) : add/replace a command at the back of the menu
  • menu:addcommand (command, submenu, ...) : add/replace a command after the item or into the submenu. You can also provide sub submenus.

Note that MainMenu is not always available, for instance when Guerilla is executed without UI, or when the Guerilla export plugin the is executed.

local    mycommand = command.create ("MyCommand")
function mycommand:isenabled ()
    ...
end
function mycommand:action ()
    ...
end

if MainMenu then
    -- Add the command into the Modify Menu, MyCommands submenu.
    -- This creates the menus if they don't exist.
    MainMenu:addcommand (mycommand, "Modify""MyCommands")
end

Commands can also be placed in menus.

Arguments:

  • label The menu label
  • icon The menu icon, must be an bitmap file located in the ui directory of the installation, or nil if none
  • shortcut The menu key shortcut, mixing 'Ctrl', 'Shift', 'Alt' and a key separated by '+'. For instance, 'Ctrl+A', 'Ctrl+Shift+Numpad9'