Event types#
The type is the core of an event pattern — the kind of thing that happened.
Use it in a pattern as <Type> or <Type-detail>, e.g.
<KeyPress-Return> or <Button-1>.
Commonly used types#
Type |
Alias |
Fires when |
|---|---|---|
|
|
A key is pressed. The detail is a key symbol
( |
|
A key is released. |
|
|
|
A mouse button is pressed. The detail is the button number
( |
|
A mouse button is released. |
|
|
The pointer moves. Combine with a button modifier for drags:
|
|
|
The mouse wheel turns; the rotation is in |
|
|
The pointer enters the widget. |
|
|
The pointer leaves the widget. |
|
|
The widget (or a descendant) gains keyboard focus. |
|
|
The widget (or a descendant) loses keyboard focus. |
|
|
The widget changes size or position; new size is |
|
|
The widget becomes visible (mapped). |
|
|
The widget becomes hidden (unmapped). |
|
|
The widget’s visible/obscured state changes. |
|
|
All or part of the widget needs redrawing. |
|
|
The widget is being destroyed. |
|
|
The toplevel becomes the active window. |
|
|
The toplevel stops being the active window. |
|
|
An X property on the window changes (X11). |
|
|
The window’s colormap changes (X11). |
Note
MouseWheel is platform-split. On Windows and macOS, bind <MouseWheel>
and read event.delta (multiples of 120 on Windows, ±1 on macOS). On X11
(Linux) the wheel arrives as <Button-4> (up) and <Button-5> (down)
instead. Cross-platform code binds all three.
Rarely used types#
Circulate, Gravity, and Reparent report low-level X11 window changes
and are seldom useful in applications. The CirculateRequest,
ConfigureRequest, MapRequest, ResizeRequest, and Create types are
only delivered to an X11 window manager, never to an ordinary application.
Virtual event types#
A type written in double brackets — <<Paste>>, <<ThemeChanged>> — is a
virtual event, a named notification decoupled from any
one physical event.