widgets/textbox.py Fix bug with encoder scrolling.

pull/8/head
Peter Hinch 2021-07-16 18:05:22 +01:00
rodzic ba46d98216
commit 765f7bd70c
2 zmienionych plików z 8 dodań i 2 usunięć

Wyświetl plik

@ -87,7 +87,7 @@ Text may be clipped to the width of the control or may be word-wrapped. If the n
of lines of text exceeds the height available, scrolling may be performed \
by calling a method.
Please use the increase and decrease buttons to scroll this text.
Please use the increase and decrease buttons (or encoder) to scroll this text.
'''
class TBUScreen(Screen):

Wyświetl plik

@ -129,7 +129,13 @@ class Textbox(LinearIO):
self.start = max(0, min(line, len(self.lines) - self.nlines))
self.draw = True # Cause a refresh
async def btnhan(self, button, up):
def do_adj(self, button, val):
if isinstance(button, int): # Using an encoder
self.scroll(val)
else:
asyncio.create_task(self.btn_handler(button, val))
async def btn_handler(self, button, up): # Only runs if not using encoder
self.scroll(-up)
t = ticks_ms()
d = 1