Package pygsear :: Module Event :: Class Repeat_KEY_Event
[show private | hide private]
[frames | no frames]

Class Repeat_KEY_Event

object --+            
         |            
    Sprite --+        
             |        
         Event --+    
                 |    
         KEY_Event --+
                     |
                    Repeat_KEY_Event


KEY_Event which will auto-repeat after a delay.

if no key parameter is passed in, this Event will listen for all keyboard keypress events. Since the only thing I am using this for right now is for text input, I made the behavior somewhat like a command line interface. Specifically: shift, alt, and ctrl are treated specially and will not repeat. I considered keeping track of a dict of active keypress, but it seemed like much work for little gain. It should not be too difficult though if someone needs that functionality.
Method Summary
  __init__(self, key, on_press, on_hold, on_release, delay, period, **kwargs)
Initialize a keyboard event that will auto-repeat when the key is held.
  press(self, ev)
Do nothing, so we can handle the on_hold a different way here.
  release(self, ev)
Do nothing, so we can handle the on_hold a different way here.
  rhold(self, ev)
Call the callback at the requested interval.
  rpress(self, ev)
Start counting down the delay time until auto-repeat kicks in.
  rrelease(self, ev)
Reset the counters.
    Inherited from KEY_Event
  call(self, pygame_event, **kwargs)
Perform the callback, if the event is enabled, and the key pressed is the right key.
  check_holding(self, ev, **kwargs)
    Inherited from Event
  add(self, group)
Add this Event to an EventGroup.
  disable(self)
Do not allow callbacks to go through.
  enable(self)
Allow callbacks to go through.
  nop(self, ev, **kwargs)
Do nothing.
    Inherited from Sprite
  __repr__(self)
  add_internal(self, group)
  alive(self)
alive() -> bool check to see if the sprite is in any groups
  groups(self)
groups() -> list of groups list used sprite containers
  kill(self)
kill() remove this sprite from all groups
  remove(self, *groups)
remove(group or list of groups, ...) remove a sprite from container
  remove_internal(self, group)
  update(self, *args)
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)
    Inherited from type
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T

Method Details

__init__(self, key=None, on_press=None, on_hold=None, on_release=None, delay=400, period=50, **kwargs)
(Constructor)

Initialize a keyboard event that will auto-repeat when the key is held.
Parameters:
key - The keyboard key which will trigger this event, or a sequence of keys. (ie: Pressing any one of these keys will trigger the event) If key is None then any keypress will fire the callback.
on_press - Function to call when key is first pressed
on_hold - Function to call while key is being held down. Will be called once every period milliseconds after delay milliseconds.
on_release - Function to call when key is finally released
delay - Time to wait before starting auto-repeat (in milliseconds)
period - Time between auto-repeat calls to on_hold(in milliseconds)
kwargs - Additional parameters that should be passed on to the callback.
Overrides:
pygsear.Event.KEY_Event.__init__

press(self, ev)

Do nothing, so we can handle the on_hold a different way here.
Overrides:
pygsear.Event.KEY_Event.press

release(self, ev)

Do nothing, so we can handle the on_hold a different way here.
Overrides:
pygsear.Event.KEY_Event.release

rhold(self, ev)

Call the callback at the requested interval.

rpress(self, ev)

Start counting down the delay time until auto-repeat kicks in.

rrelease(self, ev)

Reset the counters.

Generated by Epydoc 2.0 on Sat Dec 9 14:11:20 2006 http://epydoc.sf.net