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.
_KeyListener Base class for key-related events.
_MouseButton The current state of a single mouse button.
_MouseButtonListener Base class for mouse-related events
_MouseClickDragListener Base class for mouse drag/click-related events
    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()
  _clickdrag_mouse_press(event)
  _clickdrag_mouse_release(event)
  _drag_update()

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                                                           
list _buttons = [<pajammin.input._MouseButton instance at 0x1...
tuple _EVENTS = (24, 6, 5, 3, 2)
bool _initialized = False
list _listeners = [<pajammin.input.MousePressListener instanc...
int _NUM_BUTTONS = 10                                                                    

Function Details

handle_events()

_clickdrag_mouse_press(event)

_clickdrag_mouse_release(event)

_drag_update()


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                                                           

_buttons

Type:
list
Value:
[<pajammin.input._MouseButton instance at 0x10bf5a8>,
 <pajammin.input._MouseButton instance at 0x10bfaa8>,
 <pajammin.input._MouseButton instance at 0x10bfa30>,
 <pajammin.input._MouseButton instance at 0x10bf6e8>,
 <pajammin.input._MouseButton instance at 0x10bf648>,
 <pajammin.input._MouseButton instance at 0x10bf800>,
 <pajammin.input._MouseButton instance at 0x10bf878>,
 <pajammin.input._MouseButton instance at 0x10bf968>,
...                                                                    

_EVENTS

Type:
tuple
Value:
(24, 6, 5, 3, 2)                                                       

_initialized

Type:
bool
Value:
False                                                                  

_listeners

Type:
list
Value:
[<pajammin.input.MousePressListener instance at 0x10d2c60>,
 <pajammin.input.MouseReleaseListener instance at 0x10d2c88>]          

_NUM_BUTTONS

Type:
int
Value:
10