command.createΒΆ
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 labelicon The command icon, must be an bitmap file located in the ui directory of the installation, or nil if noneshortcut The command key shortcut, mixing 'Ctrl', 'Shift', 'Alt' and a key separated by '+'. For instance, 'Ctrl+A', 'Ctrl+Shift+Numpad9'