Skip to content

Commit 6777864

Browse files
0HyperCubeKeavon
authored andcommitted
Fix properties deselect (#606)
* Fix properties panel deselect * Fix arrow cursors on select tool * Fix drag from UI to document causing mouse down * Fix tests * Cleanup
1 parent 1bf1687 commit 6777864

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

editor/src/document/properties_panel_message_handler.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ impl<'a> MessageHandler<PropertiesPanelMessage, PropertiesPanelMessageHandlerDat
148148
}
149149
.into(),
150150
);
151+
self.active_selection = None;
151152
}
152153
ModifyFont {
153154
font_family,
@@ -231,11 +232,12 @@ impl<'a> MessageHandler<PropertiesPanelMessage, PropertiesPanelMessageHandlerDat
231232
}
232233
}
233234
ResendActiveProperties => {
234-
let (path, target_document) = self.active_selection.clone().expect("Received update for properties panel with no active layer");
235-
let layer = get_document(target_document).layer(&path).unwrap();
236-
match target_document {
237-
TargetDocument::Artboard => register_artboard_layer_properties(layer, responses, &get_document(target_document).font_cache),
238-
TargetDocument::Artwork => register_artwork_layer_properties(layer, responses, &get_document(target_document).font_cache),
235+
if let Some((path, target_document)) = self.active_selection.clone() {
236+
let layer = get_document(target_document).layer(&path).unwrap();
237+
match target_document {
238+
TargetDocument::Artboard => register_artboard_layer_properties(layer, responses, &get_document(target_document).font_cache),
239+
TargetDocument::Artwork => register_artwork_layer_properties(layer, responses, &get_document(target_document).font_cache),
240+
}
239241
}
240242
}
241243
}

editor/src/input/input_preprocessor_message_handler.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl MessageHandler<InputPreprocessorMessage, ()> for InputPreprocessorMessageHa
8383
let mouse_state = editor_mouse_state.to_mouse_state(&self.viewport_bounds);
8484
self.mouse.position = mouse_state.position;
8585

86-
self.translate_mouse_event(mouse_state, responses);
86+
self.translate_mouse_event(mouse_state, true, responses);
8787
}
8888
InputPreprocessorMessage::PointerMove { editor_mouse_state, modifier_keys } => {
8989
self.handle_modifier_keys(modifier_keys, responses);
@@ -94,15 +94,15 @@ impl MessageHandler<InputPreprocessorMessage, ()> for InputPreprocessorMessageHa
9494
responses.push_back(InputMapperMessage::PointerMove.into());
9595

9696
// While any pointer button is already down, additional button down events are not reported, but they are sent as `pointermove` events
97-
self.translate_mouse_event(mouse_state, responses);
97+
self.translate_mouse_event(mouse_state, false, responses);
9898
}
9999
InputPreprocessorMessage::PointerUp { editor_mouse_state, modifier_keys } => {
100100
self.handle_modifier_keys(modifier_keys, responses);
101101

102102
let mouse_state = editor_mouse_state.to_mouse_state(&self.viewport_bounds);
103103
self.mouse.position = mouse_state.position;
104104

105-
self.translate_mouse_event(mouse_state, responses);
105+
self.translate_mouse_event(mouse_state, false, responses);
106106
}
107107
};
108108
}
@@ -114,12 +114,12 @@ impl MessageHandler<InputPreprocessorMessage, ()> for InputPreprocessorMessageHa
114114
}
115115

116116
impl InputPreprocessorMessageHandler {
117-
fn translate_mouse_event(&mut self, new_state: MouseState, responses: &mut VecDeque<Message>) {
117+
fn translate_mouse_event(&mut self, new_state: MouseState, allow_first_button_down: bool, responses: &mut VecDeque<Message>) {
118118
for (bit_flag, key) in [(MouseKeys::LEFT, Key::Lmb), (MouseKeys::RIGHT, Key::Rmb), (MouseKeys::MIDDLE, Key::Mmb)] {
119119
// Calculate the intersection between the two key states
120120
let old_down = self.mouse.mouse_keys & bit_flag == bit_flag;
121121
let new_down = new_state.mouse_keys & bit_flag == bit_flag;
122-
if !old_down && new_down {
122+
if !old_down && new_down && (allow_first_button_down || self.mouse.mouse_keys != MouseKeys::NONE) {
123123
responses.push_back(InputMapperMessage::KeyDown(key).into());
124124
}
125125
if old_down && !new_down {

frontend/src/lifetime/input.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,8 @@ export function createInputManager(editor: EditorState, container: HTMLElement,
108108
const onPointerMove = (e: PointerEvent): void => {
109109
if (!e.buttons) viewportPointerInteractionOngoing = false;
110110

111-
if (viewportPointerInteractionOngoing) {
112-
const modifiers = makeModifiersBitfield(e);
113-
editor.instance.on_mouse_move(e.clientX, e.clientY, e.buttons, modifiers);
114-
}
111+
const modifiers = makeModifiersBitfield(e);
112+
editor.instance.on_mouse_move(e.clientX, e.clientY, e.buttons, modifiers);
115113
};
116114

117115
const onPointerDown = (e: PointerEvent): void => {

0 commit comments

Comments
 (0)