beetlebug▾
/

event

Defines virtual events, and sends events to widgets from a script.

event SUBCOMMAND ?ARG ...?

Description

A virtual event has a name in double angle brackets, such as <<Save>>, and one or more physical sequences. When a physical sequence occurs in a widget, a binding of the virtual event on a tag of the widget runs, as bind describes. A widget can also get a virtual event from event generate alone, with no sequence.

event generate sends an event to a widget at once, as if it came from the platform. A test drives the bindings of a widget with it, also in ztk --headless.

Subcommands

SubcommandDescription
event addAdds physical sequences to a virtual event.
event deleteRemoves sequences from a virtual event, or removes the virtual event.
event infoGives the virtual events, or the sequences of one virtual event.
event generateSends one event to a widget at once, and runs its bindings.

Examples

# The key F5 is a sequence of `<<Go>>`, so the binding of `<<Go>>` runs.
% frame .f -width 20 -height 20
> pack .f
> update
> event add <<Go>> <Key-F5>
> bind .f <<Go>> {set ::go 1}
> focus .f
> event generate .f <Key-F5>
> set go
1

Errors

% event
wrong # args: should be "event option ?arg1 arg2 ...?"
-errorcode TCL WRONGARGS

% event bogus
bad option "bogus": must be add, delete, generate, or info
-errorcode NONE

Differences from Tcl

Facts

Capability
None.
Tcl release
Tcl 9.1 and 8.6.
Since
ztk 1.0.0-beta.1

See also