--- a/tuikit/core/container.py Fri Mar 28 14:58:20 2014 +0100
+++ b/tuikit/core/container.py Fri Mar 28 19:58:59 2014 +0100
@@ -1,4 +1,5 @@
from tuikit.core.widget import Widget
+from tuikit.core.coords import Point
from tuikit.layouts.fixed import FixedLayout
@@ -14,6 +15,7 @@
Widget.__init__(self)
#: List of child widgets.
self.children = []
+ self.focus_child = None
self.layout = layout_class()
def add(self, widget):
@@ -23,6 +25,8 @@
widget.window = self.window
widget.set_theme(self.theme)
self.layout.add(widget)
+ if self.focus_child is None:
+ self.focus_child = widget
def resize(self, w, h):
Widget.resize(self, w, h)
@@ -41,3 +45,19 @@
Widget.set_theme(self, theme)
for child in self.children:
child.set_theme(theme)
+
+ @property
+ def cursor(self):
+ if self.focus_child:
+ cursor = self.focus_child.cursor
+ if cursor is not None:
+ return cursor.moved(*self.focus_child.pos)
+ else:
+ if self._cursor is not None:
+ return Point(self._cursor)
+
+ ## input events ##
+
+ def keypress(self, keyname, char, mod=0):
+ if self.focus_child:
+ self.focus_child.keypress(keyname, char, mod)