# Class LTerm_widget.t

    class t : string -> object .. end

The base class. The parameter is the initial resource class. The resource class is the first part of all resource keys used by the widget.

For examples, buttons use the resources `"button.focused.foreground"`, `"button.unfocused.bold"`, ... so their resource class is `"button"`.

The children of the widget.

    method children : t list

The children of the widget.

    method parent : t option

The parent of the widget, if any.

    method set_parent : t option -> unit

Sets the parent of the widget. This also affect `LTerm_widget.t.queue_draw`.

    method can_focus : bool

Whether the widget can receive the focus or not.

    method queue_draw : unit

Enqueue a redraw operation. If the widget has a parent, this is the same as calling the `LTerm_widget.t.queue_draw` method of the parent, otherwise this does nothing.

    method set_queue_draw : (unit -> unit) -> unit

`set_queue_draw f` sets the function called when the `LTerm_widget.t.queue_draw` method is invoked, for this widget and all its children.

    method draw : LTerm_draw.context -> t -> unit

`draw ctx focused` draws the widget on the given context. `focused` is the focused widget.

    method cursor_position : LTerm_geom.coord option

Method invoked when the widget has the focus, it returns the position of the cursor inside the widget if it should be displayed.

    method allocation : LTerm_geom.rect

The zone occuped by the widget.

    method set_allocation : LTerm_geom.rect -> unit

Sets the zone occuped by the widget.

    method send_event : LTerm_event.t -> unit

Send an event to the widget. If the widget cannot process the event, it is sent to the parent and so on.

    method on_event : ?switch:switch -> (LTerm_event.t -> bool) -> unit

`on_event ?switch f` calls `f` each time an event is received. If `f` returns `true`, the event is not passed to other callbacks.

    method size_request : LTerm_geom.size

The size wanted by the widget.

    method resources : LTerm_resources.t

The set of resources used by the widget.

    method set_resources : LTerm_resources.t -> unit

Sets the resources of the widget and of all its children.

    method resource_class : string

The resource class of the widget.

    method set_resource_class : string -> unit

Sets the resource class of the widget. This can be used to set an alternative style for the widget.

    method update_resources : unit

Method invoked when the resources or the resource class of the widget change. The default function does nothing.