diff --git a/python_payload/st3m/ui/menu.py b/python_payload/st3m/ui/menu.py index efcc8c59207115210d1e6b826dad8839b2d8f63d..a502b69c3617e0e448d7f33552c6b076106917ca 100644 --- a/python_payload/st3m/ui/menu.py +++ b/python_payload/st3m/ui/menu.py @@ -46,6 +46,12 @@ class MenuItem(Responder): """ pass + def highlight(self, active: bool) -> None: + """ + Called when the item starts or stops being highlighted. + """ + pass + def draw(self, ctx: Context) -> None: ctx.text(self.label()) @@ -197,10 +203,16 @@ class MenuController(BaseView): self._scroll_controller.think(ins, delta_ms) + target = self._scroll_controller.target_position() + if self.input.buttons.app.middle.pressed: self.select() self._parse_state() + if self._scroll_controller.target_position() != target: + self._items[target].highlight(False) + self._items[self._scroll_controller.target_position()].highlight(True) + def draw(self, ctx: Context) -> None: pass