Skip to main content

kiln.ui.widget

Registers redraw triggers and returns the supplied declaration function.

local draw = ui.widget(spec)

Example​

Register once during config setup:

local draw_time = ui.widget {
every = 1,
fn = function() ui.text(os.date("%H:%M:%S")) end,
}

Call draw_time() inside a bar or another declaration.

Options​

FieldTypeDefaultBehaviour
fn or [1]functionrequiredDeclaration function. fn takes precedence.
watcharray of strings{}"class::signal" names, such as "client::focus". The class must be a global with an on method.
everynumbernilRedraw interval in seconds. Must be positive.

Behaviour​

A watched signal or timer marks all outputs dirty. Watches are shared by signal name. Each every registration starts its own repeating timer, including when its declaration function is not drawn.

There is no per-widget stop handle. Reload removes registered watches and cancels timers. Register again during config setup. Invalid watch names, a missing function or a non-positive interval raise an error.