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

Class Listener

Known Subclasses:
KeyListener, MouseListener

An input dispatcher that listens for a specific type of input event, and when it occurs, calls a callback function. Different subclasses of Listener are used to listen for different input event types.

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 the only listener notified for that event.
Method Summary
  __init__(self, callback, cbdata, priority)
Construct a new listener.
  __cmp__(self, other)
  handle(self, event)
  is_relevant(self, event)
Return true if this listener's callback should be notified about the given event.
  start(self)
  stop(self)

Method Details

__init__(self, callback, cbdata=(), priority=50)
(Constructor)

Construct a new listener.
Parameters:
callback - The listener's callback function. When an relevant event occurs, this callback will be called with the event object, plus any arguments specified in cbdata.
cbdata - A tuple containing extra arguments for the callback function.
priority - The priority of this listener.

__cmp__(self, other)
(Comparison operator)

handle(self, event)

is_relevant(self, event)

Return true if this listener's callback should be notified about the given event.

start(self)

stop(self)