Skip to content

Commit 202d8a8

Browse files
committed
Shortcut
1 parent e4a6b46 commit 202d8a8

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
@@ -239,6 +239,8 @@ pub enum Key {
239239
FakeKeyPlus,
240240
/// 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.
241241
FakeKeyNumbers,
242+
/// Not a physical key that can be pressed.
243+
Double,
242244

243245
_KeysVariantCount, // This has to be the last element in the enum
244246
}
@@ -330,6 +332,7 @@ impl fmt::Display for Key {
330332
// Fake keys for displaying special labels in the UI
331333
Self::FakeKeyPlus => "+",
332334
Self::FakeKeyNumbers => "0–9",
335+
Self::Double => "2x",
333336

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

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;
@@ -120,4 +121,16 @@ pub enum MouseButton {
120121
Forward,
121122
}
122123

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

0 commit comments

Comments
 (0)