# HG changeset patch # User phoku@33b003aa-7bff-0310-803a-e67f0ece8222 # Date 1237493689 0 # Node ID c050f257cec3e48f1938c00977f5c08bf1be94ce # Parent e901bdec7578bb0b52d2e6087e67ff4929bf9957 PyChan: Now Widgets may _in principle_ receive key events. diff -r e901bdec7578 -r c050f257cec3 clients/pychan_demo/pychan_test.py --- a/clients/pychan_demo/pychan_test.py Thu Mar 19 19:04:07 2009 +0000 +++ b/clients/pychan_demo/pychan_test.py Thu Mar 19 20:14:49 2009 +0000 @@ -68,6 +68,9 @@ credits = self.gui.findChild(name="creditsLink") credits.setEnterCallback(lambda w : credits._setText("CREDITS")) credits.capture(lambda : credits._setText("Credits"), event_name="mouseExited") + def pr(event=None): + print event + self.gui.capture(pr,event_name="keyPressed") from dynamic import DynamicExample from styling import StylingExample diff -r e901bdec7578 -r c050f257cec3 engine/core/gui/guilistener.i --- a/engine/core/gui/guilistener.i Thu Mar 19 19:04:07 2009 +0000 +++ b/engine/core/gui/guilistener.i Thu Mar 19 20:14:49 2009 +0000 @@ -49,10 +49,11 @@ %feature("director") KeyListener; class KeyListener { public: - virtual ~KeyListener() { } + virtual ~KeyListener(); - virtual void keyPressed(gcn::KeyEvent& keyEvent) { } - virtual void keyReleased(gcn::KeyEvent& keyEvent) { } + virtual void keyPressed(gcn::KeyEvent& keyEvent); + virtual void keyReleased(gcn::KeyEvent& keyEvent); + protected: KeyListener() { } }; diff -r e901bdec7578 -r c050f257cec3 engine/extensions/pychan/compat.py --- a/engine/extensions/pychan/compat.py Thu Mar 19 19:04:07 2009 +0000 +++ b/engine/extensions/pychan/compat.py Thu Mar 19 20:14:49 2009 +0000 @@ -75,7 +75,7 @@ fife = guichan guichan.ActionListener._ActionListener_init__ = lambda x : x #guichan.MouseListener.__init__ = lambda x : x - guichan.KeyListener.__init__ = lambda x : x + #guichan.KeyListener.__init__ = lambda x : x else: guichan.Point = _point guichan.ScrollArea.SHOW_AUTO = guichan.ScrollArea.ShowAuto