Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
François Revol
firmware
Commits
f34b58ca
Commit
f34b58ca
authored
Nov 10, 2019
by
Philip Stewart
Committed by
Rahix
Nov 10, 2019
Browse files
feat(simple-menu): Add option to use right buttons for scrolling
parent
db14781c
Changes
1
Hide whitespace changes
Inline
Side-by-side
pycardium/modules/py/simple_menu.py
View file @
f34b58ca
...
...
@@ -120,6 +120,12 @@ class Menu:
.. versionadded:: 1.9
"""
right_buttons_scroll
=
False
"""
Use top right and bottom right buttons to move in the list
instead of bottom left and bottom right buttons.
"""
def
on_scroll
(
self
,
item
,
index
):
"""
Hook when the selector scrolls to a new item.
...
...
@@ -173,6 +179,12 @@ class Menu:
self
.
idx
=
0
self
.
select_time
=
utime
.
time_ms
()
self
.
disp
=
display
.
open
()
self
.
button_scroll_up
=
(
buttons
.
TOP_RIGHT
if
self
.
right_buttons_scroll
else
buttons
.
BOTTOM_LEFT
)
self
.
button_select
=
(
buttons
.
BOTTOM_LEFT
if
self
.
right_buttons_scroll
else
buttons
.
TOP_RIGHT
)
def
entry2name
(
self
,
value
):
"""
...
...
@@ -290,7 +302,7 @@ class Menu:
except
Exception
as
e
:
print
(
"Exception during menu.on_scroll():"
)
sys
.
print_exception
(
e
)
elif
ev
==
button
s
.
BOTTOM_LEFT
:
elif
ev
==
self
.
button
_scroll_up
:
self
.
select_time
=
utime
.
time_ms
()
self
.
draw_menu
(
8
)
self
.
idx
=
(
self
.
idx
+
len
(
self
.
entries
)
-
1
)
%
len
(
self
.
entries
)
...
...
@@ -301,7 +313,7 @@ class Menu:
except
Exception
as
e
:
print
(
"Exception during menu.on_scroll():"
)
sys
.
print_exception
(
e
)
elif
ev
==
button
s
.
TOP_RIGHT
:
elif
ev
==
self
.
button
_select
:
try
:
self
.
on_select
(
self
.
entries
[
self
.
idx
],
self
.
idx
)
self
.
select_time
=
utime
.
time_ms
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment