Skip to content
Snippets Groups Projects
Commit 50a8a541 authored by dos's avatar dos Committed by ave
Browse files

py,st3m: MenuController: Let MenuItems know whether they're highlighted

parent 2862643e
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment