changeset 222:c050f257cec3

PyChan: Now Widgets may _in principle_ receive key events.
author phoku@33b003aa-7bff-0310-803a-e67f0ece8222
date Thu, 19 Mar 2009 20:14:49 +0000
parents e901bdec7578
children da2ca208c221
files clients/pychan_demo/pychan_test.py engine/core/gui/guilistener.i engine/extensions/pychan/compat.py
diffstat 3 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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() { }
 	};
--- 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