7 Widgets and the Buffer

This chapter describes commands that are specific to buffers that contain widgets.

Const: widget-keymap

Keymap containing useful bindings for buffers containing widgets.

Binds TAB and C-TAB to widget-forward and widget-backward, respectively. It also binds RET to widget-button-press and down-mouse-1 and down-mouse-2 to widget-button-click.

There’s also a keymap for events that the Widget library doesn’t need to handle.

Variable: widget-global-map

Keymap used by widget-button-press and widget-button-click when not on a button. By default this is global-map.

In addition to these two keymaps, each widget might define a keymap of its own, active when events happen at that widget.

The following navigation commands are available:

TAB
Command: widget-forward &optional count

Move point count buttons or editing fields forward.

M-TAB
S-TAB
Command: widget-backward &optional count

Move point count buttons or editing fields backward.

When editing an editable-field widget, the following commands are available:

C-e
Command: widget-end-of-line

Move point to the end of field or end of line, whichever is first.

C-k
Command: widget-kill-line

Kill to end of field or end of line, whichever is first.

M-TAB
Command: widget-complete

Complete the content of the editable field at point.

C-m
Command: widget-field-activate

Invoke the editable field at point.

The following two are commands that can execute widget actions.

RET
Command: widget-button-press pos &optional event

Invoke the button at pos, defaulting to point.

Invocation means to run the function stored in the :action property.

If point is not located on a button, invoke the binding in widget-global-map (by default the global map).

mouse-2
Command: widget-button-click event

Invoke the button at the location of the mouse pointer.

If the mouse pointer is located in an editable text field, invoke the binding in widget-global-map (by default the global map).

In case the mouse-click is on a widget, calls the function stored in the :mouse-down-action property.