Rework hide stuff to make hidden the property and hide/show the control
This commit is contained in:
parent
2e9d633cdc
commit
764d27f8a6
2 changed files with 14 additions and 6 deletions
|
|
@ -162,12 +162,12 @@ class Cursor(object):
|
||||||
self._cursor_grp.y = y_val
|
self._cursor_grp.y = y_val
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def hide(self):
|
def hidden(self):
|
||||||
"""Returns True if the cursor is hidden or visible on the display."""
|
"""Returns True if the cursor is hidden or visible on the display."""
|
||||||
return self._is_hidden
|
return self._is_hidden
|
||||||
|
|
||||||
@hide.setter
|
@hidden.setter
|
||||||
def hide(self, is_hidden):
|
def hidden(self, is_hidden):
|
||||||
self._is_deinited()
|
self._is_deinited()
|
||||||
if is_hidden:
|
if is_hidden:
|
||||||
self._is_hidden = True
|
self._is_hidden = True
|
||||||
|
|
@ -176,6 +176,14 @@ class Cursor(object):
|
||||||
self._is_hidden = False
|
self._is_hidden = False
|
||||||
self._display_grp.append(self._cursor_grp)
|
self._display_grp.append(self._cursor_grp)
|
||||||
|
|
||||||
|
def hide(self):
|
||||||
|
"""Hide the cursor."""
|
||||||
|
self.hidden = True
|
||||||
|
|
||||||
|
def show(self):
|
||||||
|
"""Show the cursor."""
|
||||||
|
self.hidden = False
|
||||||
|
|
||||||
#pylint:disable=no-self-use
|
#pylint:disable=no-self-use
|
||||||
def _default_cursor_bitmap(self):
|
def _default_cursor_bitmap(self):
|
||||||
bmp = displayio.Bitmap(20, 20, 3)
|
bmp = displayio.Bitmap(20, 20, 3)
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@ display.show(splash)
|
||||||
while True:
|
while True:
|
||||||
cursor.update()
|
cursor.update()
|
||||||
if cursor.is_clicked:
|
if cursor.is_clicked:
|
||||||
if mouse_cursor.hide:
|
if mouse_cursor.hidden:
|
||||||
mouse_cursor.hide = False
|
mouse_cursor.show()
|
||||||
else:
|
else:
|
||||||
mouse_cursor.hide = True
|
mouse_cursor.hide()
|
||||||
time.sleep(0.01)
|
time.sleep(0.01)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue