Skip to content

Add support to use mouse buttons (including X1 & X2) as shortcuts (fix #598)#4927

Merged
dacap merged 5 commits into
aseprite:betafrom
dacap:new-shortcuts
Dec 5, 2025
Merged

Add support to use mouse buttons (including X1 & X2) as shortcuts (fix #598)#4927
dacap merged 5 commits into
aseprite:betafrom
dacap:new-shortcuts

Conversation

@dacap

@dacap dacap commented Jan 10, 2025

Copy link
Copy Markdown
Member

This is a work-in-progress to fix #598

@dacap dacap self-assigned this Jan 10, 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

Comment thread src/app/app_menus.cpp
Comment thread src/app/commands/cmd_keyboard_shortcuts.cpp
Comment thread src/app/commands/cmd_keyboard_shortcuts.cpp
Comment thread src/app/commands/cmd_keyboard_shortcuts.cpp Outdated
Comment thread src/app/ui/key.h Outdated
Comment thread src/app/ui/keyboard_shortcuts.cpp Outdated
const KeyboardShortcuts& globalKeys,
const KeyContext keyContext) const
const ui::Shortcut* Key::isPressed(const Message* msg,
const KeyboardShortcuts& globalKeys,

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: parameter 'globalKeys' is unused [misc-unused-parameters]

Suggested change
const KeyboardShortcuts& globalKeys,
const KeyboardShortcuts& /*globalKeys*/,

Comment thread src/app/ui/keyboard_shortcuts.cpp Outdated
Comment thread src/app/ui/keyboard_shortcuts.cpp
Comment thread src/app/ui/keyboard_shortcuts.h Outdated
Comment thread src/app/ui/keyboard_shortcuts.h Outdated
@dacap dacap linked an issue Jan 10, 2025 that may be closed by this pull request

@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

Comment thread src/ui/manager.cpp

@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

Comment thread src/app/ui/select_shortcut.cpp
Comment thread src/app/ui/select_shortcut.cpp
Comment thread src/app/ui/select_shortcut.cpp
Comment thread src/app/ui/select_shortcut.cpp
{
bool state = (checkbox->isSelected());
KeyModifiers modifiers = m_shortcut.modifiers();
KeyScancode scancode = m_shortcut.scancode();

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 'scancode' of type 'KeyScancode' (aka 'os::KeyScancode') can be declared 'const' [misc-const-correctness]

Suggested change
KeyScancode scancode = m_shortcut.scancode();
KeyScancode const scancode = m_shortcut.scancode();

Comment thread src/app/ui/select_shortcut.cpp Outdated
alt()->setSelected(m_shortcut.modifiers() & kKeyAltModifier ? true : false);
ctrl()->setSelected(m_shortcut.modifiers() & kKeyCtrlModifier ? true : false);
shift()->setSelected(m_shortcut.modifiers() & kKeyShiftModifier ? true : false);
space()->setSelected(m_shortcut.modifiers() & kKeySpaceModifier ? true : false);

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: implicit conversion 'int' -> 'bool' [readability-implicit-bool-conversion]

  space()->setSelected(m_shortcut.modifiers() & kKeySpaceModifier ? true : false);
                       ^

this fix will not be applied because it overlaps with another fix

Comment thread src/app/ui/select_shortcut.cpp Outdated
alt()->setSelected(m_shortcut.modifiers() & kKeyAltModifier ? true : false);
ctrl()->setSelected(m_shortcut.modifiers() & kKeyCtrlModifier ? true : false);
shift()->setSelected(m_shortcut.modifiers() & kKeyShiftModifier ? true : false);
space()->setSelected(m_shortcut.modifiers() & kKeySpaceModifier ? true : false);

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: redundant boolean literal in ternary expression result [readability-simplify-boolean-expr]

Suggested change
space()->setSelected(m_shortcut.modifiers() & kKeySpaceModifier ? true : false);
space()->setSelected((m_shortcut.modifiers() & kKeySpaceModifier) != 0);

Comment thread src/app/ui/select_shortcut.cpp Outdated
"Also known as Windows key, logo key,\ncommand key, or system key.",
TOP);
#endif
win()->setSelected(m_shortcut.modifiers() & kKeyWinModifier ? true : false);

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: implicit conversion 'int' -> 'bool' [readability-implicit-bool-conversion]

  win()->setSelected(m_shortcut.modifiers() & kKeyWinModifier ? true : false);
                     ^

this fix will not be applied because it overlaps with another fix

Comment thread src/app/ui/select_shortcut.cpp Outdated
"Also known as Windows key, logo key,\ncommand key, or system key.",
TOP);
#endif
win()->setSelected(m_shortcut.modifiers() & kKeyWinModifier ? true : false);

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: redundant boolean literal in ternary expression result [readability-simplify-boolean-expr]

Suggested change
win()->setSelected(m_shortcut.modifiers() & kKeyWinModifier ? true : false);
win()->setSelected((m_shortcut.modifiers() & kKeyWinModifier) != 0);

Comment thread src/app/ui/select_shortcut.cpp
@dacap dacap force-pushed the new-shortcuts branch 2 times, most recently from d4c2bbb to b1da5f8 Compare September 1, 2025 21:37
@dacap dacap force-pushed the new-shortcuts branch 2 times, most recently from 0996744 to e96ad18 Compare December 4, 2025 15:22

@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

Comment thread src/app/ui/doc_view.cpp Outdated
Comment thread src/app/ui/doc_view.cpp Outdated
Comment thread src/app/ui/keyboard_shortcuts.cpp Outdated
dacap added 2 commits December 5, 2025 15:42
Without this patch assigning the same mouse button shortcut to a
command would delete its assignment at all.
@dacap dacap marked this pull request as ready for review December 5, 2025 19:32

@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

}
}

bool 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:

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

}

Keys KeyboardShortcuts::getDragActionsFromKeyMessage(const ui::Message* msg)
Keys KeyboardShortcuts::getDragActionsFromMessage(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 'getDragActionsFromMessage' can be made static [readability-convert-member-functions-to-static]

src/app/ui/keyboard_shortcuts.h:78:

-   Keys getDragActionsFromMessage(const ui::Message* msg);
+   static Keys getDragActionsFromMessage(const ui::Message* msg);

@dacap dacap merged commit 8d48b43 into aseprite:beta Dec 5, 2025
12 checks passed
@dacap dacap deleted the new-shortcuts branch December 5, 2025 19:48
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.

Make special mouse buttons customizable

2 participants