diff --git a/gui/demos/tbox.py b/gui/demos/tbox.py index 5a09367..7440548 100644 --- a/gui/demos/tbox.py +++ b/gui/demos/tbox.py @@ -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): diff --git a/gui/widgets/textbox.py b/gui/widgets/textbox.py index 8119c25..293747d 100644 --- a/gui/widgets/textbox.py +++ b/gui/widgets/textbox.py @@ -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