EventsModule
The events module contains utilities for decoding ../PicoGUI events. Most
of these utilities are part of the Event class, but there are two
useful dictionaries - kmods, mapping mnemonic names of keyboard
modifiers to the corresponding bitmask, and typenames, mapping event
type codes to mnemonic names. Still, when using these to deal with
events, you should rather use them trough the Event class, via the
hasMod() method and the name attribute.
The Event class
Event objects have only one useful method, hasMod(), which then
again only applies to keyboard events. It expects one parameter, a
string describing a keyboard modifier (like "shift" or "lshift")
- case is ignored - and returns true if the specified modifier was
active in this event.
Most useful information is in instance attributes:
-
name - string representation of the event type, like
"kbd_char"or"close" -
type - numeric representation of the event type (don't use it unless you're very sure of what you're doing)
-
widget_id - handle to the widget that generated the event, or None if it was a non-widget event
-
data - the undecoded parameter data. This is an
intfor events withEVENTCODING_PARAMorEVENTCODING_KBDand a string forEVENTCODING_DATA. In other cases it won't be present. -
xandy - coordinates or size, for events where this applies.
-
buttons - for pointer events, the bitmask of pointer buttons that were active.
-
chbuttons - for pointer events, the bitmask of pointer buttons that changed since last event.
-
char - for keyboard events, when the event translates into a character, it is stored in this attribute. It may be either a string or unicode object.
-
mods - for keyboard events, the bitmask of keyboard modifiers
that were active. Don't use this unless you know what you're doing -
instead, call the method
hasMod().
Status: UpToDateStatus