Skip to content

Addressing hotkey issues#8797

Open
VicenteCartas wants to merge 3 commits intoMegaMek:mainfrom
VicenteCartas:vicentecartas/hotkeys
Open

Addressing hotkey issues#8797
VicenteCartas wants to merge 3 commits intoMegaMek:mainfrom
VicenteCartas:vicentecartas/hotkeys

Conversation

@VicenteCartas
Copy link
Collaborator

@VicenteCartas VicenteCartas commented Mar 9, 2026

Addresses #6712

Some panels use ALT+KEY to open, like for example Interstellar Map (ALT+S). But that conflicts with ALT+S setup for save in the app menu. I have changed the critical menu shortcuts (CTRL+S, CTRL+N, CTRL+L) to use CTRL instead of ALT (the convention used in megamek) so there are no clashes. All other accelerators with Alt are removed because they were already conflicting with each other (multiple options registered to things like Alt+P). mnemonics still work as expected.

@VicenteCartas VicenteCartas requested a review from a team as a code owner March 9, 2026 02:36
Copilot AI review requested due to automatic review settings March 9, 2026 02:36
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

This PR updates MekHQ’s main Campaign GUI menu accelerators to avoid conflicts between Swing’s tab mnemonics (Alt+key) and menu item accelerators, addressing the hotkey clash described in #6712.

Changes:

  • Switched many JMenuItem accelerators from Alt+<key> to Ctrl+<key> in CampaignGUI.initMenu().
  • Updated the initMenu() JavaDoc to document the rationale (avoiding conflicts with MHQTabType tab mnemonics).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Mar 9, 2026

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 13.23%. Comparing base (6e9f6a0) to head (cc4e8a7).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
MekHQ/src/mekhq/gui/CampaignGUI.java 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               main    #8797   +/-   ##
=========================================
  Coverage     13.22%   13.23%           
- Complexity     7874     7875    +1     
=========================================
  Files          1306     1306           
  Lines        169191   169139   -52     
  Branches      25458    25458           
=========================================
- Hits          22383    22382    -1     
+ Misses       144632   144579   -53     
- Partials       2176     2178    +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@psikomonkie
Copy link
Member

This might be silly, but have you tested how this change interacts with playing a MegaMek scenario from MekHQ? If you use "CTRL-S" to save in a MegaMek scenario launched from MekHQ, will it trigger the save action on MekHQ too?

@VicenteCartas
Copy link
Collaborator Author

This might be silly, but have you tested how this change interacts with playing a MegaMek scenario from MekHQ? If you use "CTRL-S" to save in a MegaMek scenario launched from MekHQ, will it trigger the save action on MekHQ too?

I have not, but JMenuItem registers accelerators in the WHEN_IN_FOCUSED_WINDOW , which means only the focused window gets the event. Per Oracle docs:

https://docs.oracle.com/javase/tutorial/uiswing/misc/keybinding.html
image

@VicenteCartas
Copy link
Collaborator Author

This might be silly, but have you tested how this change interacts with playing a MegaMek scenario from MekHQ? If you use "CTRL-S" to save in a MegaMek scenario launched from MekHQ, will it trigger the save action on MekHQ too?

Double checked in the programs themselves, saving in one with CTRL+S doesn't trigger the save on the other.

Copy link
Member

@psikomonkie psikomonkie left a comment

Choose a reason for hiding this comment

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

Nice! Thanks for double checking that for me. The ctrl-vs-alt situation just gave me a weird vibe, like it was intentional. Glad it won't be an issue!

@VicenteCartas
Copy link
Collaborator Author

@psikomonkie If you can merge for me, appreciated :)

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.

3 participants