mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-27 00:28:10 +00:00
trezor.ui.keyboard: complete suggestion on click
This commit is contained in:
parent
b15d60383e
commit
e94d8cc277
@ -53,6 +53,7 @@ class KeyboardMultiTap:
|
|||||||
self.pending_index = 0
|
self.pending_index = 0
|
||||||
|
|
||||||
self.key_buttons = key_buttons()
|
self.key_buttons = key_buttons()
|
||||||
|
self.sugg_button = Button((5, 5, 240 - 35, 30), '')
|
||||||
self.bs_button = Button((240 - 35, 5, 30, 30),
|
self.bs_button = Button((240 - 35, 5, 30, 30),
|
||||||
res.load('trezor/res/pin_close.toig'),
|
res.load('trezor/res/pin_close.toig'),
|
||||||
normal_style=CLEAR_BUTTON,
|
normal_style=CLEAR_BUTTON,
|
||||||
@ -97,6 +98,13 @@ class KeyboardMultiTap:
|
|||||||
self._update_suggestion()
|
self._update_suggestion()
|
||||||
self._update_buttons()
|
self._update_buttons()
|
||||||
return
|
return
|
||||||
|
if self.sugg_button.touch(event, pos) == BTN_CLICKED and self.sugg_word is not None:
|
||||||
|
self.content = self.sugg_word
|
||||||
|
self.pending_button = None
|
||||||
|
self.pending_index = 0
|
||||||
|
self._update_suggestion()
|
||||||
|
self._update_buttons()
|
||||||
|
return
|
||||||
for btn in self.key_buttons:
|
for btn in self.key_buttons:
|
||||||
if btn.touch(event, pos) == BTN_CLICKED:
|
if btn.touch(event, pos) == BTN_CLICKED:
|
||||||
if self.pending_button is btn:
|
if self.pending_button is btn:
|
||||||
@ -108,8 +116,6 @@ class KeyboardMultiTap:
|
|||||||
else:
|
else:
|
||||||
self.content += btn.content[0]
|
self.content += btn.content[0]
|
||||||
self._update_suggestion()
|
self._update_suggestion()
|
||||||
if self.pending_button:
|
|
||||||
self._update_buttons()
|
|
||||||
self.pending_button = btn
|
self.pending_button = btn
|
||||||
self.pending_index = 0
|
self.pending_index = 0
|
||||||
return
|
return
|
||||||
@ -130,14 +136,14 @@ class KeyboardMultiTap:
|
|||||||
btn.disable()
|
btn.disable()
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
|
timeout = loop.Sleep(1000 * 1000 * 1)
|
||||||
|
touch = loop.Select(loop.TOUCH)
|
||||||
|
wait = loop.Wait((touch, timeout))
|
||||||
while True:
|
while True:
|
||||||
self.render()
|
self.render()
|
||||||
timeout = loop.Sleep(1000 * 1000 * 1)
|
result = yield wait
|
||||||
touch = loop.Select(loop.TOUCH)
|
|
||||||
wait = loop.Wait((touch, timeout))
|
|
||||||
event = yield wait
|
|
||||||
if touch in wait.finished:
|
if touch in wait.finished:
|
||||||
event, *pos = event
|
event, *pos = result
|
||||||
self.touch(event, pos)
|
self.touch(event, pos)
|
||||||
else:
|
else:
|
||||||
self.pending_button = None
|
self.pending_button = None
|
||||||
@ -217,14 +223,14 @@ class KeyboardZooming:
|
|||||||
break
|
break
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
|
timeout = loop.Sleep(1000 * 1000 * 1)
|
||||||
|
touch = loop.Select(loop.TOUCH)
|
||||||
|
wait = loop.Wait((touch, timeout))
|
||||||
while True:
|
while True:
|
||||||
self.render()
|
self.render()
|
||||||
timeout = loop.Sleep(1000 * 1000 * 1)
|
result = yield wait
|
||||||
touch = loop.Select(loop.TOUCH)
|
|
||||||
wait = loop.Wait((touch, timeout))
|
|
||||||
event = yield wait
|
|
||||||
if touch in wait.finished:
|
if touch in wait.finished:
|
||||||
event, *pos = event
|
event, *pos = result
|
||||||
self.touch(event, pos)
|
self.touch(event, pos)
|
||||||
elif self.zoom_buttons:
|
elif self.zoom_buttons:
|
||||||
self.zoom_buttons = None
|
self.zoom_buttons = None
|
||||||
|
Loading…
Reference in New Issue
Block a user