Skip to content

Add keyboard shortcuts for gizmo menu#591

Merged
tracygardner merged 6 commits into
flipcomputing:mainfrom
lawsie:shortcuts-for-gizmos
Apr 30, 2026
Merged

Add keyboard shortcuts for gizmo menu#591
tracygardner merged 6 commits into
flipcomputing:mainfrom
lawsie:shortcuts-for-gizmos

Conversation

@lawsie
Copy link
Copy Markdown
Contributor

@lawsie lawsie commented Apr 30, 2026

Summary

When the gizmo menu is activated with Ctrl + G, shortcut keys 1-9 appear below each gizmo. You can press the number key to activate the gizmo while this overlay is active.

image
  • Gizmos should not activate if you enter numeric values in input boxes, even if the overlay is visible
  • Turn the overlay off with Ctrl + G
  • Normal tab behaviour should still work, this is meant to be an additional option
  • If no gizmo is focused, Ctrl + G will bring focus to the first gizmo. If a gizmo was already in use, Ctrl + G will leave the focus where it was but show the overlay.

AI usage

This was mostly a reimplementation of the area overlay (which I have renamed for clarity) but with different styles. Claude Sonnet 4.6 helped me find out why tab was initially not functioning, because I'd forgotten to remove some of the AreaOverlay functionality for tabs which wasn't needed for this overlay.

Summary by CodeRabbit

  • New Features

    • Added a gizmo menu overlay accessible via Ctrl+G, displaying numeric key badges for quick access to controls
    • Number keys (1–9) now navigate and activate corresponding gizmo buttons
  • Style

    • Improved panel spacing and layout adjustments

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 30, 2026

Warning

Rate limit exceeded

@lawsie has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 51 minutes and 37 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 971867ea-8e6e-47cf-927b-337d57735cae

📥 Commits

Reviewing files that changed from the base of the PR and between 24408b4 and 5bb4d58.

📒 Files selected for processing (1)
  • main/accessibility.js
📝 Walkthrough

Walkthrough

The PR refactors the area overlay controller, renaming AccessibilityManager to AreaManager, and introduces a new GizmoMenuManager for keyboard-driven gizmo activation. It adds Ctrl+G toggle support, numeric key badges (1-9) for gizmo buttons, and intelligent form field input detection to prevent shortcut interference.

Changes

Cohort / File(s) Summary
Accessibility Manager Refactor
main/accessibility.js
Renamed AccessibilityManager to AreaManager while preserving existing keyboard behavior (Ctrl+B, Escape, Tab, Enter). Added new GizmoMenuManager class that toggles #gizmo-menu-overlay via Ctrl+G, renders numeric key badges above gizmo buttons, focuses showShapesButton by default, detects form field/contenteditable input to ignore shortcuts, and maps number keys (1–9) to focus and click corresponding gizmo button. Startup initialization updated to instantiate both managers.
Overlay and Badge Styling
style.css
Increased #info-panel margin-top from 15px to 25px. Added fixed, full-screen #gizmo-menu-overlay with pointer-events: none to prevent interaction capture. Introduced .gizmo-key-badge style for centered numeric labels rendered above gizmo buttons.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

  • Keyboard controls for gizmos: #360: Directly addresses the addition of single-key keyboard controls (1-9, Ctrl+G) for gizmo activation and input-typing behavior detection to prevent shortcut interference.

Possibly related PRs

  • Improve area menu #590: Modifies overlapping area-overlay accessibility code, including keyboard navigation, badge rendering, and gizmo button activation patterns.
  • Area menu overlay #588: Shares modifications in main/accessibility.js with similar area overlay and keyboard focus behavior implementation.

Poem

🐰 A gizmo shortcut, swift and neat,
Ctrl+G makes keyboard fun complete!
Nine little badges, shining bright,
Number keys activate with might.
Smart enough to skip form text,
Navigation magic comes next!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add keyboard shortcuts for gizmo menu' directly and clearly summarizes the main change: implementing keyboard shortcuts (1-9) to activate gizmos when the menu overlay is toggled with Ctrl+G.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 51 minutes and 37 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
main/accessibility.js (1)

226-232: ⚡ Quick win

Only close the overlay after a successful activatable target is found.

Right now, a disabled/unavailable button still dismisses the menu. Keep the overlay open unless activation can actually occur.

Suggested refactor
   activateButton(entry) {
-    this.toggle(false);
     const el = document.getElementById(entry.id);
-    if (!el) return;
+    if (!el || el.disabled || el.offsetParent === null) return;
+    this.toggle(false);
     el.focus();
-    if (!el.disabled) el.click();
+    el.click();
   },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@main/accessibility.js` around lines 226 - 232, In activateButton, don't call
this.toggle(false) until you've confirmed an activatable element was found and
activation succeeded: move the this.toggle(false) call to after verifying const
el = document.getElementById(entry.id) exists and is not disabled, then focus
and click it and only then call this.toggle(false); if el is missing or
el.disabled is true, do not dismiss the overlay (return early). Reference:
activateButton, this.toggle, entry.id, el.disabled, el.focus, el.click.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@main/accessibility.js`:
- Around line 178-184: The focus check only inspects document.activeElement
within `#gizmoButtons`; instead also detect whether a gizmo is currently active
and skip focusing when one is active. Modify the logic around the existing gizmo
focus block (references: `#gizmoButtons` and getElementById("showShapesButton"))
to add a guard like checking a known active-gizmo signal (for example a global
state variable such as window.activeGizmo, an element with a class like
.gizmo-active, or a data attribute e.g. [data-gizmo-active="true"]) and treat
that as equivalent to alreadyFocused; only call btn.focus() when neither an
element inside `#gizmoButtons` is focused nor any active-gizmo indicator exists.
Ensure the new check is used wherever Ctrl+G focus behavior is handled so active
gizmo usage preserves focus.

---

Nitpick comments:
In `@main/accessibility.js`:
- Around line 226-232: In activateButton, don't call this.toggle(false) until
you've confirmed an activatable element was found and activation succeeded: move
the this.toggle(false) call to after verifying const el =
document.getElementById(entry.id) exists and is not disabled, then focus and
click it and only then call this.toggle(false); if el is missing or el.disabled
is true, do not dismiss the overlay (return early). Reference: activateButton,
this.toggle, entry.id, el.disabled, el.focus, el.click.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 64ff4233-3171-468c-ba6f-0f7a7bb3f498

📥 Commits

Reviewing files that changed from the base of the PR and between 2570145 and 24408b4.

📒 Files selected for processing (2)
  • main/accessibility.js
  • style.css

Comment thread main/accessibility.js
@lawsie lawsie mentioned this pull request Apr 30, 2026
23 tasks
@tracygardner tracygardner merged commit 9c21282 into flipcomputing:main Apr 30, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants