command.createΒΆ

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

Create a command

This function creates a new command. A command may perform actions on the UI or the document. A command must implement the action and isenabled methods:

local    printcommand = command.create ("Print Selection"nil"Ctrl+Shift+D")
function printcommand:isenabled ()
    return true
end
function printcommand:action ()
    local    selection = Document:getselection ()
    if selection then
        for k, node in pairs (selection) do
            print (node:getname ())
        end
    end
end

Commands can also be placed in menus.

Commands action method can optionally take a window and current x, y mouse position.

Arguments:

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