-
-
Notifications
You must be signed in to change notification settings - Fork 2k
skip header items when enabling the InkHUD menu cursor #9552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Updates InkHUD’s menu navigation so that when the menu cursor is first revealed, it skips over non-selectable header items and lands on the first/last actionable entry. This improves usability on menus that include section headers.
Changes:
- Update
onButtonShortPress()to select the first non-header item when showing the cursor. - Update
onNavDown()similarly to select the first non-header item when showing the cursor. - Update
onNavUp()to select the last non-header item when showing the cursor.
| // Select the last item that isn't a header | ||
| cursor = items.size() - 1; | ||
| while (items.at(cursor).isHeader) { | ||
| if (cursor == 0) { | ||
| cursorShown = false; | ||
| break; |
Copilot
AI
Feb 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onNavUp() sets cursor = items.size() - 1 without guarding for items.empty(). If the items list is empty (e.g., a transient state during page changes), this underflows and items.at(cursor) will throw/abort. Add an early items.empty() check (and keep cursorShown false) before computing the last index, similar to the defensive handling used in onNavDown()/onButtonShortPress().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem to be checked in any of the other places where the cursor moved or set. Should I add this guard everywhere the cursor is moved?
| // Select the first item that isn't a header | ||
| cursor = 0; | ||
| while (cursor < items.size() && items.at(cursor).isHeader) | ||
| cursor++; | ||
| if (cursor >= items.size()) { | ||
| cursorShown = false; | ||
| cursor = 0; | ||
| } |
Copilot
AI
Feb 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The “select first non-header item” logic is duplicated in both onButtonShortPress() and onNavDown(). Consider extracting it into a small helper (and similarly for the “select last non-header” logic) to keep cursor-reveal behavior consistent and reduce the chance of future drift when header-handling changes.
Modify
onButtonShortPress()andonNavDown()so that when revealing the cursor by settingcursorShowntotrue, they select the first non-header item.onNavUp()functions similarly but selects the last non-header item.