Fix cursor.
authorRadek Brich <radek.brich@devl.cz>
Wed, 03 Sep 2014 08:57:24 +0200
changeset 108 11dac45bfba4
parent 107 1822c37b2688
child 113 6796adfdc7eb
Fix cursor.
tuikit/core/container.py
tuikit/core/coords.py
tuikit/core/window.py
tuikit/widgets/textbox.py
--- a/tuikit/core/container.py	Wed Sep 03 08:57:06 2014 +0200
+++ b/tuikit/core/container.py	Wed Sep 03 08:57:24 2014 +0200
@@ -1,5 +1,5 @@
 from tuikit.core.widget import Widget
-from tuikit.core.coords import Point
+from tuikit.core.coords import Point, Rect
 from tuikit.layouts.fixed import FixedLayout
 
 
@@ -57,11 +57,13 @@
         """
         if self.focus_child:
             cursor = self.focus_child.cursor
-            if cursor is not None:
-                return cursor.moved(*self.focus_child.pos)
+            if not cursor:
+                return None
+            cursor = cursor.moved(*self.focus_child.pos)
         else:
-            if self._cursor in Rect._make((0, 0), self._size):
-                return self._cursor
+            cursor = self._cursor.immutable()
+        if cursor in Rect._make((0, 0), self._size):
+            return cursor
 
     ## input events ##
 
--- a/tuikit/core/coords.py	Wed Sep 03 08:57:06 2014 +0200
+++ b/tuikit/core/coords.py	Wed Sep 03 08:57:24 2014 +0200
@@ -107,6 +107,9 @@
     def y(self):
         return self._y
 
+    def moved(self, relx, rely):
+        return ImmutablePoint(self.x + relx, self.y + rely)
+
     def __getitem__(self, key):
         return (self.x, self.y)[key]
 
--- a/tuikit/core/window.py	Wed Sep 03 08:57:06 2014 +0200
+++ b/tuikit/core/window.py	Wed Sep 03 08:57:24 2014 +0200
@@ -58,6 +58,7 @@
         self.timer = timer
 
     def resize(self, w, h):
+        Container.resize(self, w, h)
         self.children[0].resize(w, h)
 
     def handle_event(self, event_name, *args):
--- a/tuikit/widgets/textbox.py	Wed Sep 03 08:57:06 2014 +0200
+++ b/tuikit/widgets/textbox.py	Wed Sep 03 08:57:24 2014 +0200
@@ -22,6 +22,7 @@
         # This variable rememberes horizontal position of cursor
         # for the case when cursor moves to shorter line.
         self.cursor_column = 0
+        self._cursor.update(0, 0)
         # selection - line and column of selection start
         self.sel_line = 0
         self.sel_column = 0