Ipelib: Lua bindings for Ipe

Ipelib

- Main Page
- Modules
- Classes

# Lua bindings for Ipe

These are the Lua methods provided by the Ipe program itself. They are only available to Lua code running inside Ipe.

## Application user interface

The application user interface object provides the GUI for the Ipe program.

    -- model is a Lua table containing methods that will be called
    -- by the ui when events occur
    ui = AppUi(model)

    id = ui:win()      -- returns window id of window
    -- (to be used as parent for dialogs)
    ui:close()         -- close window

    ui:setActionState(name, t) -- set whether action is checked
    t = ui:actionState(name)   -- is action checked?

    ui:explain(text)     -- show message in status bar for a few seconds
    ui:setWindowTitle(caption)

    ui:showNotes(n)

    -- make a tool visible or invisible
    -- tool is one of "layers", "properties", "bookmarks", "notes"
    -- t is true or false
    ui:showTool(tool, t)

    -- set contents of attribute selectors from style sheet
    ui:setupSymbolicNames(styleSheet)

    -- set attribute values displayed in user interface
    -- 'attributes' table see below
    ui:setAttributes(styleSheet, attributes)

    -- set layer list from page
    ui:setLayers(page, view)

    ui:setActionState(action_name, true_or_false)
    state = ui:actionState(action_name)

    -- select one page and return page number (or nil if canceled)
    pno = ui:selectPage(doc)
    -- select one view and return view number (or nil if canceled)
    vno = ui:selectPage(doc, page_no)

The following methods work on the canvas inside the UI:

    ui:setPage(page, pgno, view, styleSheet) -- set page shown on canvas
    ui:setSnap(snap)                    -- for 'snap' table see below
    ui:setFontPool(p)       -- an opaque object obtained from an ipe.Document

    -- 'pan' is a vector indicating the user coordinates at canvas center
    v = ui:pan()
    ui:setPan(v)

    zoom = ui:zoom()        -- a number
    ui:setZoom(zoom)

    v = ui:pos()            -- current mouse position, after snapping
    v = ui:unsnappedPos()   -- current mouse position, before snapping
    v = ui:simpleSnapPos()  -- same, but ignoring angular snap
    v = ui:globalPos()      -- mouse position on screen

    v = ui:canvasSize()     -- size of canvas in pixels

    ui:setNumbering(t)      -- true or false
    ui:setFifiVisible(t)    -- true or false
    ui:setSelectionVisible(t) -- true or false

    ui:update()             -- update canvas and tool
    ui:update(false)        -- update tool only
    ui:finishTool()

    ui:panTool()
    ui:selectTool()
    ui:transformTool()
    ui:shapeTool()