Widget

Widget

new Widget(defaultPropsopt, propsopt)

Source:

Widget class

Parameters:
Name Type Attributes Default Description
defaultProps object.<string, *> <optional>
{}
props object.<string, *> <optional>
{}

Methods

(static) declare(Class, BaseClassopt, proto) → {class}

Source:

Define a Widget derived class

Parameters:
Name Type Attributes Default Description
Class class

The class to define

BaseClass class <optional>
Widget

The base class

proto object

The class' prototype object

Returns:

The Class parameter

Type
class

draw()

Source:
See:

Draw the widget in the associated window

get_size() → {WindowSize}

Source:

Return underlying window size

Returns:
Type
WindowSize

get_win() → {Window}

Source:

Get associated window

Returns:
Type
Window

invalidate()

Source:

Invalidate window contents, i.e.: mark widget as modified so that next drawing cycle refreshes screen contents.

is_disabled() → {boolean}

Source:

Check whether the widget is disabled.

Returns:
Type
boolean

merge_keymap(map)

Source:
See:

Merge some key mappings with current active keymap

Example
widget.merge_keymap([
  tui.KEY_UP, 'go_up',
  tui.KEY_DOWN, 'go_down',
]);
Parameters:
Name Type Description
map Array

An array of alternating key number, function name elements.

send_key(key) → {boolean}

Source:
See:

Send a key to the widget so that it is processed according to the active keymap.

Parameters:
Name Type Description
key number

Key code

Returns:

Returns true if the key was processed

Type
boolean

set_disabled(disabled)

Source:
See:

Disable widget so that it won't receive any keyboard input at all from module:wui.send_key.

Parameters:
Name Type Description
disabled boolean

set_keymap(map)

Source:
See:

Overwrite current active keymap with new key mappings

Example
widget.set_keymap([
  tui.KEY_UP, 'go_up',
  tui.KEY_DOWN, 'go_down',
]);
Parameters:
Name Type Description
map Array

An array of alternating key number, function name elements.

set_listeners(listeners)

Source:

Overwrite current listeners map with a new map

Parameters:
Name Type Description
listeners object.<string, WidgetListener>

set_win(win)

Source:

Set associated window object. Note that this function invalidates the window contents so that it is cleared on next redraw.

Parameters:
Name Type Description
win Window