Skip to content

Conversation

@zeropt
Copy link
Contributor

@zeropt zeropt commented Feb 6, 2026

Modify onButtonShortPress() and onNavDown() so that when revealing the cursor by setting cursorShown to true, they select the first non-header item. onNavUp() functions similarly but selects the last non-header item.

  • I have tested that my proposed changes behave as described.
  • I have tested that my proposed changes do not cause any obvious regressions on the following devices:
    • Seeed Wio Tracker L1 E-ink

@github-actions github-actions bot added needs-review Needs human review enhancement New feature or request labels Feb 6, 2026
Copy link
Contributor

Copilot AI left a 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.

Comment on lines +1586 to +1591
// Select the last item that isn't a header
cursor = items.size() - 1;
while (items.at(cursor).isHeader) {
if (cursor == 0) {
cursorShown = false;
break;
Copy link

Copilot AI Feb 7, 2026

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().

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

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?

Comment on lines 1527 to 1534
// 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;
}
Copy link

Copilot AI Feb 7, 2026

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.

Copilot uses AI. Check for mistakes.
@HarukiToreda HarukiToreda added the InkHUD Issues directly related to InkHUD UI label Feb 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request InkHUD Issues directly related to InkHUD UI needs-review Needs human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants