Skip to content

Fix several regressions with key shortcuts#5590

Merged
dacap merged 5 commits into
aseprite:betafrom
dacap:fix-keys
Dec 12, 2025
Merged

Fix several regressions with key shortcuts#5590
dacap merged 5 commits into
aseprite:betafrom
dacap:fix-keys

Conversation

@dacap

@dacap dacap commented Dec 12, 2025

Copy link
Copy Markdown
Member

fix #5585
fix #5588
fix #5589
fix #5591

Can be used for debugging purposes/log events.
…atest mouse down event (fix aseprite#5588)

E.g. if we have a key like "F" assigned to quick select the
eyedropper, when we click the left mouse button, we have to prioritize
the quick tool selected with the "F" key, as the left mouse button
alone doesn't have any modifier/no quick tool associated, it should
just trigger the current quick tool.

With this patch, the pressed shortcut with more modifiers wins over
the shortcut with less modifiers to select a new quick tool.
…seprite#5589)

The shift+pencil to paint a straight line wasn't making possible to
associate a button like shift+x2 to (e.g.) drag the brush size.
@dacap dacap self-assigned this Dec 12, 2025

@aseprite-bot aseprite-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

clang-tidy made some suggestions


atm->newQuickToolSelectedFromEditor(newQuicktool);
tools::Tool* prevQuicktool = atm->quickTool();
ui::Shortcut prevShortcut = atm->quickToolFromShortcut();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

warning: variable 'prevShortcut' of type 'ui::Shortcut' can be declared 'const' [misc-const-correctness]

Suggested change
ui::Shortcut prevShortcut = atm->quickToolFromShortcut();
ui::Shortcut const prevShortcut = atm->quickToolFromShortcut();

}

bool StandbyState::handleDragActionsFromMessage(Editor* editor, const ui::Message* msg)
EditorStatePtr StandbyState::handleDragActionsFromMessage(Editor* editor, const ui::Message* msg)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

warning: method 'handleDragActionsFromMessage' can be made static [readability-convert-member-functions-to-static]

src/app/ui/editor/standby_state.h:58:

-   EditorStatePtr handleDragActionsFromMessage(Editor* editor, const ui::Message* msg);
+   static EditorStatePtr handleDragActionsFromMessage(Editor* editor, const ui::Message* msg);

if (hasFocus() && !isReadOnly()) {
KeyMessage* keymsg = static_cast<KeyMessage*>(msg);
if (!keymsg->scancode() && keymsg->unicodeChar() < 32)
Shortcut shortcut = msg->shortcut();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

warning: variable 'shortcut' of type 'Shortcut' can be declared 'const' [misc-const-correctness]

Suggested change
Shortcut shortcut = msg->shortcut();
Shortcut const shortcut = msg->shortcut();

Comment thread src/ui/shortcut.cpp
case kKeyRControl: newModifier = kKeyCtrlModifier; break;
case kKeyAlt: newModifier = kKeyAltModifier; break;
case kKeyAltGr:
newModifier = (KeyModifiers)((int)kKeyAltModifier | (int)kKeyCtrlModifier);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

warning: The value '6' provided to the cast expression is not in the valid range of values for 'KeyModifiers' [clang-analyzer-optin.core.EnumCastOutOfRange]

      newModifier = (KeyModifiers)((int)kKeyAltModifier | (int)kKeyCtrlModifier);
                    ^
Additional context

laf/os/keys.h:12: enum declared here

enum KeyModifiers {
     ^

src/ui/shortcut.cpp:408: Control jumps to 'case kKeyAltGr:' at line 415

  switch (m_scancode) {
  ^

src/ui/shortcut.cpp:415: The value '6' provided to the cast expression is not in the valid range of values for 'KeyModifiers'

      newModifier = (KeyModifiers)((int)kKeyAltModifier | (int)kKeyCtrlModifier);
                    ^

@dacap dacap linked an issue Dec 12, 2025 that may be closed by this pull request
@dacap dacap marked this pull request as ready for review December 12, 2025 15:01
@dacap dacap merged commit a6d97a0 into aseprite:beta Dec 12, 2025
11 of 12 checks passed
@dacap dacap deleted the fix-keys branch December 12, 2025 15:08
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.

Menus aren't clickeable Cannot use Shift+X2 to drag brush size Cannot use F key as eyedropper (quick) Cannot copy selection (regression)

2 participants