tuikit/core/widget.py
changeset 104 742e504ec053
parent 97 0c2e0c09ba5c
child 105 70c9cfc70cd6
--- a/tuikit/core/widget.py	Wed Aug 27 23:09:53 2014 +0200
+++ b/tuikit/core/widget.py	Mon Sep 01 08:45:51 2014 +0200
@@ -1,4 +1,4 @@
-from tuikit.core.coords import Point, Size
+from tuikit.core.coords import Point, Size, Rect
 from tuikit.core.theme import default_theme
 
 import logging
@@ -41,8 +41,9 @@
 
         #: Cursor is position where text input will occur.
         #: It is displayed on screen if widget is active.
-        #: None means no cursor (hidden).
-        self._cursor = None
+        #: The cursor coordinates are relative to widget.
+        #: Position outside of widget boundaries means no cursor (hidden).
+        self._cursor = Point(-1, -1)
 
     ## position and size ##
 
@@ -93,8 +94,10 @@
 
     @property
     def cursor(self):
-        if self._cursor is not None:
-            return Point(self._cursor)
+        """Return cursor coordinates or None if cursor is not set
+        or is set outside of widget boundaries."""
+        if self._cursor in Rect._make((0, 0), self._size):
+            return self._cursor
 
     ## input events ##