Package pajammin :: Module input
[show private | hide private]
[frames | no frames]

Module pajammin.input

The input handler for pajammin. The input handler is a dispatcher which responds to keyboard and mouse input events by delegating them to registered callbacks.

To register a callback, create a listener for that callback, which specifies exactly which events you are interested in, and call its start() method. E.g.:
>>> KeyPressListener(my_callback, key='x').start()

Listener is an abstract base class; different subclasses of Listener are used to listen for different types of events.

When a listener encounters a relevant event, it will call its callback function with that event as its first argument. (Extra arguments for the callback can be given to the Listener constructor using the cbdata parameter.) For different listeners, this event object will define different data. The following list specifies which fields the event object defines, for each listener type: Each listener has a priority, which determines the order in which listeners are consulted. For each event, the relevant listener with the highest priority will be notified first. If it returns False (or None), then no other listeners will be notified. If it returns True, then the listener with the next lowest priority will be notified, and its return value will be checked. This continues until a listener returns False or all listeners are notified.
Classes
Listener An input dispatcher that listens for a specific type of input event, and when it occurs, calls a callback function.
    Listeners
KeyListener An input listener that monitors one or more keys.
KeyReleaseListener An event listener that reports key releases.
KeyPressListener An event listener that reports key presses.
MouseListener An input listener that monitors one or more mouse buttons..
MouseClickListener An event listener that reports mouse clicks.
MouseDragStartListener An event listener that reports when mouse dragging starts.
MouseReleaseListener An event listener that reports mouse releases.
MouseDragStopListener An event listener that reports when mouse dragging stops.
MouseDragListener An event listener that reports mouse dragging.
MousePressListener An event listener that reports mouse presses.

Function Summary
  handle_events()

Variable Summary
int CLICK_DIST = 1                                                                     
float CLICK_TIME = 0.10000000000000001                                                   
int HIGH_PRIORITY = 80                                                                    
int LOW_PRIORITY = 20                                                                    
  LOW_PRIORITY, MEDIUM_PRIORITY, HIGH_PRIORITY: Standard priority values for listeners.
int MEDIUM_PRIORITY = 50                                                                    
int priority = -2147483647                                                           

Function Details

handle_events()


Variable Details

CLICK_DIST

Type:
int
Value:
1                                                                     

CLICK_TIME

Type:
float
Value:
0.10000000000000001                                                   

HIGH_PRIORITY

Type:
int
Value:
80                                                                    

LOW_PRIORITY

Type:
int
Value:
20                                                                    

LOW_PRIORITY, MEDIUM_PRIORITY, HIGH_PRIORITY

Standard priority values for listeners.

MEDIUM_PRIORITY

Type:
int
Value:
50                                                                    

priority

Type:
int
Value:
-2147483647