Skip to content

feat: F1-F5 keyboard shortcuts and hex color input in color picker#10816

Open
BenJule wants to merge 2 commits into
bambulab:masterfrom
BenJule:feat/keyboard-shortcuts-hex-color
Open

feat: F1-F5 keyboard shortcuts and hex color input in color picker#10816
BenJule wants to merge 2 commits into
bambulab:masterfrom
BenJule:feat/keyboard-shortcuts-hex-color

Conversation

@BenJule

@BenJule BenJule commented May 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • F1–F5 keyboard shortcuts for the main tabs and reslice action:
    • F1 → 3D Editor tab
    • F2 → Preview tab
    • F3 → Monitor tab
    • F4 → Project tab
    • F5 → Reslice (if a model is loaded)
  • Hex color input in the ColorPickerPopup: a #RRGGBB text field appears below the custom color swatch. Typing a valid 6-digit hex code and pressing Enter applies the color immediately. Clicking any preset or AMS color swatch updates the hex field to reflect the selected color.

Closes #313
Closes #1515
Closes #5078
Closes #10726

Details

Keyboard shortcuts (MainFrame.cpp)

Added a block in the existing wxEVT_CHAR_HOOK handler that intercepts F1–F5 before the canvas shortcut forwarding block. Only fires when no modifier keys are held, so existing debugger / browser F-key bindings are unaffected.

Hex color input (AMSMaterialsSetting.cpp/.hpp)

  • TextInput* m_hex_input added to ColorPickerPopup.
  • A # label and the TextInput (max 6 chars, wxTE_PROCESS_ENTER) are placed in a horizontal sizer added at the bottom of the popup.
  • wxEVT_TEXT_ENTER parses the hex string, calls set_def_colour(), and fires EVT_SELECTED_COLOR to the parent — the same path used by swatch clicks.
  • set_def_colour() now calls ChangeValue() on the hex field to keep it in sync whenever a swatch is clicked.

Test plan

  • F1-F5 switch tabs / trigger reslice correctly from the main window
  • F-keys do not interfere with text input fields (modifier guard)
  • Color picker popup shows hex input below the custom color area
  • Typing a valid 6-char hex + Enter changes the filament color
  • Typing an invalid hex (wrong length or non-hex chars) does nothing
  • Clicking a color swatch updates the hex field to the correct value
  • Transparent / empty color clears the hex field
@BenJule BenJule force-pushed the feat/keyboard-shortcuts-hex-color branch 2 times, most recently from e18c136 to add1a40 Compare May 21, 2026 08:55
@BenJule BenJule closed this Jun 7, 2026
@BenJule BenJule deleted the feat/keyboard-shortcuts-hex-color branch June 7, 2026 10:09
@BenJule BenJule restored the feat/keyboard-shortcuts-hex-color branch June 7, 2026 11:38
@BenJule BenJule reopened this Jun 7, 2026
@BenJule

BenJule commented Jun 7, 2026

Copy link
Copy Markdown
Contributor Author

Apologies — this PR was closed by mistake on 2026-06-07, and that was an error on my side, not a deliberate decision to withdraw the change.

It happened as an unintended side effect of a branch cleanup in my fork: deleting the head branch automatically closed this PR. The contribution still stands. I have restored the branch and reopened the PR. Sorry for the noise and any confusion this caused.

@BenJule BenJule force-pushed the feat/keyboard-shortcuts-hex-color branch from add1a40 to 40e8ea1 Compare June 8, 2026 05:24
@BenJule

BenJule commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

Force-pushed: rebased onto current master and reduced this PR to the feature's own source changes. The previous revision had inadvertently carried translation-file (.po/.pot) edits, generated web resources, and unrelated source changes (string fixes belonging to #10811/#10813/#10814) over from the branch base — those are now removed. Heads-up: this feature series shares a few central GUI files (e.g. GUI_App.cpp, MainFrame.cpp, Preferences.hpp), so there is some overlap between my feature PRs.

@tonghao-bbl

Copy link
Copy Markdown
Contributor

These are PR for feature request being revieewing

- F1–F4 switch the main tabs (3D Editor / Preview / Monitor / Project) and
  F5 reslices, when no modifier is held.
- The AMS colour picker gains a hex input field (e.g. FF8800), kept in sync
  with the currently selected colour.

The dark-mode changes that previously rode along on this branch (shared base)
are dropped here; they live in their own PR (bambulab#11241).
@BenJule

BenJule commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

Heads-up: I force-pushed a cleaned-up version of this branch. It previously carried some dark-mode follow-system changes that had ridden along from the shared base branch — those belong to #11241, so I removed them here.

This PR is now focused on just its two features:

  • F1–F4 switch the main tabs and F5 reslices (no modifier).
  • A hex colour input in the AMS colour picker, synced with the selected colour.

Single commit on top of master, 3 files (AMSMaterialsSetting.cpp/.hpp, MainFrame.cpp).

@BambulabRobot BambulabRobot requested review from Haidiye00 and XinZhangBambu and removed request for FiredEgg-bambu, MackBambu and tonghao-bbl June 22, 2026 08:40
@Haidiye00

Copy link
Copy Markdown
Contributor

if (key_code == WXK_F5) { if (can_reslice()) reslice_now(); return; }
Can this be deleted? I think it's pretty strange. The first four switch to the corresponding page, but the fifth one doesn't.

Per review: F1-F4 switch to the corresponding main tab, so binding F5 to
reslice instead of a fifth tab was inconsistent. Drop the F5 binding.
@BenJule

BenJule commented Jun 27, 2026

Copy link
Copy Markdown
Contributor Author

Good catch - removed the F5 binding. You're right that it was inconsistent: F1-F4 each switch to a main tab, so F5 doing a reslice instead of a fifth tab didn't fit. Now only F1-F4 (tab switches) and the hex color input remain.

@Haidiye00 Haidiye00 removed their request for review June 29, 2026 01:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants