Events
Builtin events sent by Textual.
Events may be marked as "Bubbles" and "Verbose".
See the events guide for an explanation of bubbling.
Verbose events are excluded from the textual console, unless you explicitly request them with the -v
switch as follows:
Click
class
¶
Compose
class
¶
DescendantBlur
class
¶
DescendantFocus
class
¶
Hide
class
¶
Bases: Event
Sent when a widget has been hidden.
- Bubbles
- Verbose
A widget may be hidden by setting its visible
flag to False
, if it is no longer in a layout,
or if it has been offset beyond the edges of the terminal.
Idle
class
¶
Bases: Event
Sent when there are no more items in the message queue.
This is a pseudo-event in that it is created by the Textual system and doesn't go through the usual message queue.
- Bubbles
- Verbose
Key
class
¶
Bases: InputEvent
Sent when the user hits a key on the keyboard.
- Bubbles
- Verbose
Parameters
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
The key that was pressed. |
required |
character |
str | None
|
A printable character or |
required |
Attributes
Name | Type | Description |
---|---|---|
aliases |
list[str]
|
The aliases for the key, including the key itself. |
Load
class
¶
Bases: Event
Sent when the App is running but before the terminal is in application mode.
Use this event to run any set up that doesn't require any visuals such as loading configuration and binding keys.
- Bubbles
- Verbose
MouseCapture
class
¶
MouseDown
class
¶
MouseEvent
class
¶
def __init__(
self,
x,
y,
delta_x,
delta_y,
button,
shift,
meta,
ctrl,
screen_x=None,
screen_y=None,
style=None,
):
Bases: InputEvent
Sent in response to a mouse event.
- Bubbles
- Verbose
Parameters
Name | Type | Description | Default |
---|---|---|---|
x |
int
|
The relative x coordinate. |
required |
y |
int
|
The relative y coordinate. |
required |
delta_x |
int
|
Change in x since the last message. |
required |
delta_y |
int
|
Change in y since the last message. |
required |
button |
int
|
Indexed of the pressed button. |
required |
shift |
bool
|
True if the shift key is pressed. |
required |
meta |
bool
|
True if the meta key is pressed. |
required |
ctrl |
bool
|
True if the ctrl key is pressed. |
required |
screen_x |
int | None
|
The absolute x coordinate. |
None
|
screen_y |
int | None
|
The absolute y coordinate. |
None
|
style |
Style | None
|
The Rich Style under the mouse cursor. |
None
|
delta
property
¶
offset
property
¶
screen_offset
property
¶
get_content_offset
method
¶
Get offset within a widget's content area, or None if offset is not in content (i.e. padding or border).
Parameters
Name | Type | Description | Default |
---|---|---|---|
widget |
Widget
|
Widget receiving the event. |
required |
Returns
Type | Description |
---|---|
Offset | None
|
An offset where the origin is at the top left of the content area. |
get_content_offset_capture
method
¶
Get offset from a widget's content area.
This method works even if the offset is outside the widget content region.
Parameters
Name | Type | Description | Default |
---|---|---|---|
widget |
Widget
|
Widget receiving the event. |
required |
Returns
Type | Description |
---|---|
Offset
|
An offset where the origin is at the top left of the content area. |
MouseMove
class
¶
MouseRelease
class
¶
MouseScrollDown
class
¶
MouseScrollUp
class
¶
MouseUp
class
¶
Paste
class
¶
Bases: Event
Event containing text that was pasted into the Textual application. This event will only appear when running in a terminal emulator that supports bracketed paste mode. Textual will enable bracketed pastes when an app starts, and disable it when the app shuts down.
- Bubbles
- Verbose
Parameters
Name | Type | Description | Default |
---|---|---|---|
text |
str
|
The text that has been pasted. |
required |
Print
class
¶
Resize
class
¶
Bases: Event
Sent when the app or widget has been resized.
- Bubbles
- Verbose
Parameters
Name | Type | Description | Default |
---|---|---|---|
size |
Size
|
The new size of the Widget. |
required |
virtual_size |
Size
|
The virtual size (scrollable size) of the Widget. |
required |
container_size |
Size | None
|
The size of the Widget's container widget. |
None
|