Skip to content

Commit a75fc40

Browse files
committed
Shortcut
1 parent f2e07de commit a75fc40

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

editor/src/messages/input_mapper/input_mapper_message_handler.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,15 @@ impl InputMapperMessageHandler {
6969
// Append the key button for the entry
7070
use InputMapperMessage as IMM;
7171
match entry.input {
72-
IMM::KeyDown(key) | IMM::KeyUp(key) | IMM::KeyDownNoRepeat(key) | IMM::KeyUpNoRepeat(key) | IMM::DoubleTap(key) => keys.push(key),
72+
IMM::KeyDown(key) | IMM::KeyUp(key) | IMM::KeyDownNoRepeat(key) | IMM::KeyUpNoRepeat(key) => keys.push(key),
73+
IMM::DoubleTap(key) => {
74+
keys.push(Key::Double);
75+
keys.push(key);
76+
}
77+
IMM::DoubleClick(button) => {
78+
keys.push(Key::Double);
79+
keys.push(button.into());
80+
}
7381
_ => (),
7482
}
7583

editor/src/messages/input_mapper/utility_types/input_keyboard.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ pub enum Key {
240240
FakeKeyPlus,
241241
/// Not a physical key that can be pressed. May be used so that an actual shortcut bound to all ten number keys (0, ..., 9) can separately map this fake "key" as an additional binding to display the "0–9" shortcut label in the UI.
242242
FakeKeyNumbers,
243+
/// Not a physical key that can be pressed.
244+
Double,
243245

244246
_KeysVariantCount, // This has to be the last element in the enum
245247
}
@@ -331,6 +333,7 @@ impl fmt::Display for Key {
331333
// Fake keys for displaying special labels in the UI
332334
Self::FakeKeyPlus => "+",
333335
Self::FakeKeyNumbers => "0–9",
336+
Self::Double => "2x",
334337

335338
_ => key_name.as_str(),
336339
};

editor/src/messages/input_mapper/utility_types/input_mouse.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use super::input_keyboard::Key;
12
use crate::consts::DRAG_THRESHOLD;
23
use crate::messages::prelude::*;
34
use bitflags::bitflags;
@@ -121,4 +122,16 @@ pub enum MouseButton {
121122
Forward,
122123
}
123124

125+
impl From<MouseButton> for Key {
126+
fn from(mouse_button: MouseButton) -> Self {
127+
match mouse_button {
128+
MouseButton::Left => Key::MouseLeft,
129+
MouseButton::Right => Key::MouseRight,
130+
MouseButton::Middle => Key::MouseMiddle,
131+
MouseButton::Back => Key::MouseBack,
132+
MouseButton::Forward => Key::MouseForward,
133+
}
134+
}
135+
}
136+
124137
pub const NUMBER_OF_MOUSE_BUTTONS: usize = 5; // Should be the number of variants in MouseButton

0 commit comments

Comments
 (0)