Package tdl :: Module event |
[frames] | no frames]

# Module event

source code

This module handles user input.

To handle user input you will likely want to use the event.get function or create a subclass of event.App.

- event.get iterates over recent events.
- event.App passes events to the overridable methods: ev_* and key_*.

But there are other options such as event.keyWait and event.isWindowClosed.

A few event attributes are actually string constants. Here's a reference for those:

- Event.type

  'QUIT', 'KEYDOWN', 'KEYUP', 'MOUSEDOWN', 'MOUSEUP', or 'MOUSEMOTION.'

- MouseButtonEvent.button (found in MouseDown and MouseUp events)

  'LEFT', 'MIDDLE', 'RIGHT', 'SCROLLUP', 'SCROLLDOWN'

- KeyEvent.key (found in KeyDown and KeyUp events)

  'NONE', 'ESCAPE', 'BACKSPACE', 'TAB', 'ENTER', 'SHIFT', 'CONTROL', 'ALT', 'PAUSE', 'CAPSLOCK', 'PAGEUP', 'PAGEDOWN', 'END', 'HOME', 'UP', 'LEFT', 'RIGHT', 'DOWN', 'PRINTSCREEN', 'INSERT', 'DELETE', 'LWIN', 'RWIN', 'APPS', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'KP0', 'KP1', 'KP2', 'KP3', 'KP4', 'KP5', 'KP6', 'KP7', 'KP8', 'KP9', 'KPADD', 'KPSUB', 'KPDIV', 'KPMUL', 'KPDEC', 'KPENTER', 'F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'F10', 'F11', 'F12', 'NUMLOCK', 'SCROLLLOCK', 'SPACE', 'CHAR'

Classes
| Event Base Event class.
| Quit Fired when the window is closed by the user.
| KeyEvent
| KeyDown Fired when the user presses a key on the keyboard or a key repeats.
| KeyUp Fired when the user releases a key on the keyboard.
| MouseButtonEvent
| MouseDown Fired when a mouse button is pressed.
| MouseUp Fired when a mouse button is released.
| MouseMotion Fired when the mouse is moved.
| App Application framework.

Functions
iterator |
get() Flushes the event queue and returns the list of events. | source code
push(event) Push an event into the event buffer. | source code
KeyDown |
keyWait() Waits until the user presses a key. | source code
boolean |
isWindowClosed() Returns True if the exit button on the window has been clicked and stays True afterwards. | source code

Function Details

### get() | source code
Flushes the event queue and returns the list of events. This function returns Event objects that can be indentified by their type attribute or their class. Returns: iterator Returns an iterable of objects derived from Event or anything put in a push call. If the iterator is deleted or otherwise interrupted before finishing the excess items are preserved for the next call.

### push(event) | source code
Push an event into the event buffer. Parameters: `event` (Event-like object) - The event will be available on the next call to event.get. An event pushed in the middle of a get will not show until the next time get called preventing push related infinite loops.

### keyWait() | source code
Waits until the user presses a key. Then returns a KeyDown event. Key events will repeat if held down. A click to close the window will be converted into an Alt+F4 KeyDown event. Returns: KeyDown