mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-28 18:32:50 +00:00
Fix problems assigning different but similar modifiers to mouse wheel actions
For example, before this change we were depending on the order of the wheel actions. If an action were associated to <Ctrl> and other one to <Ctrl+Shift>, when we pressed <Ctrl+Shift> we weren't returning the action with most modifiers pressed (in this case <Ctrl+Shift>), but instead the one that was checked first in the for loop (which could be the one with <Ctrl>).
This commit is contained in:
parent
65bc54904d
commit
95c6af355c
@ -114,8 +114,8 @@ namespace app {
|
||||
void add(const ui::Accelerator& accel,
|
||||
const KeySource source,
|
||||
KeyboardShortcuts& globalKeys);
|
||||
bool isPressed(const ui::Message* msg,
|
||||
KeyboardShortcuts& globalKeys) const;
|
||||
const ui::Accelerator* isPressed(const ui::Message* msg,
|
||||
KeyboardShortcuts& globalKeys) const;
|
||||
bool isPressed() const;
|
||||
bool isLooselyPressed() const;
|
||||
|
||||
|
@ -266,8 +266,8 @@ void Key::add(const ui::Accelerator& accel,
|
||||
accels->add(accel);
|
||||
}
|
||||
|
||||
bool Key::isPressed(const Message* msg,
|
||||
KeyboardShortcuts& globalKeys) const
|
||||
const ui::Accelerator* Key::isPressed(const Message* msg,
|
||||
KeyboardShortcuts& globalKeys) const
|
||||
{
|
||||
if (auto keyMsg = dynamic_cast<const KeyMessage*>(msg)) {
|
||||
for (const Accelerator& accel : accels()) {
|
||||
@ -276,7 +276,7 @@ bool Key::isPressed(const Message* msg,
|
||||
keyMsg->unicodeChar()) &&
|
||||
(m_keycontext == KeyContext::Any ||
|
||||
m_keycontext == globalKeys.getCurrentKeyContext())) {
|
||||
return true;
|
||||
return &accel;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -288,11 +288,11 @@ bool Key::isPressed(const Message* msg,
|
||||
// like "sprite editor" context, or "timeline" context,
|
||||
// etc.
|
||||
m_keycontext == KeyContext::MouseWheel)) {
|
||||
return true;
|
||||
return &accel;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool Key::isPressed() const
|
||||
@ -852,13 +852,21 @@ KeyAction KeyboardShortcuts::getCurrentActionModifiers(KeyContext context)
|
||||
WheelAction KeyboardShortcuts::getWheelActionFromMouseMessage(const KeyContext context,
|
||||
const ui::Message* msg)
|
||||
{
|
||||
WheelAction wheelAction = WheelAction::None;
|
||||
const ui::Accelerator* bestAccel = nullptr;
|
||||
KeyPtr bestKey;
|
||||
for (const KeyPtr& key : m_keys) {
|
||||
if (key->type() == KeyType::WheelAction &&
|
||||
key->keycontext() == context &&
|
||||
key->isPressed(msg, *this))
|
||||
return key->wheelAction();
|
||||
key->keycontext() == context) {
|
||||
const ui::Accelerator* accel = key->isPressed(msg, *this);
|
||||
if ((accel) &&
|
||||
(!bestAccel || bestAccel->modifiers() < accel->modifiers())) {
|
||||
bestAccel = accel;
|
||||
wheelAction = key->wheelAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
return WheelAction::None;
|
||||
return wheelAction;
|
||||
}
|
||||
|
||||
bool KeyboardShortcuts::hasMouseWheelCustomization() const
|
||||
|
Loading…
x
Reference in New Issue
Block a user