Skip to content

Commit d692538

Browse files
authored
Make the Text tool delete empty text layers when clicking away wth LMB (#2192)
Fix additions of layers when using left click Fixes: https://discord.com/channels/731730685944922173/881073965047636018/1327376421034922045
1 parent 3582126 commit d692538

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

editor/src/messages/tool/tool_messages/text_tool.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub enum TextToolMessage {
6363
Interact,
6464
PointerMove { center: Key, lock_ratio: Key },
6565
PointerOutsideViewport { center: Key, lock_ratio: Key },
66-
TextChange { new_text: String, is_right_click: bool },
66+
TextChange { new_text: String, is_left_or_right_click: bool },
6767
UpdateBounds { new_text: String },
6868
UpdateOptions(TextOptionsUpdate),
6969
}
@@ -577,10 +577,10 @@ impl Fsm for TextToolFsmState {
577577
responses.add(FrontendMessage::TriggerTextCommit);
578578
TextToolFsmState::Editing
579579
}
580-
(TextToolFsmState::Editing, TextToolMessage::TextChange { new_text, is_right_click }) => {
580+
(TextToolFsmState::Editing, TextToolMessage::TextChange { new_text, is_left_or_right_click }) => {
581581
tool_data.new_text = new_text;
582582

583-
if !is_right_click {
583+
if !is_left_or_right_click {
584584
tool_data.set_editing(false, font_cache, responses);
585585

586586
responses.add(NodeGraphMessage::SetInput {

frontend/src/io-managers/input.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ export function createInputManager(editor: Editor, dialog: DialogState, portfoli
172172
}
173173

174174
if (!inTextInput && !inContextMenu) {
175-
const isRightClick = e.button === 2;
176-
if (textToolInteractiveInputElement) editor.handle.onChangeText(textInputCleanup(textToolInteractiveInputElement.innerText), isRightClick);
175+
const isLeftOrRightClick = e.button === 2 || e.button === 0;
176+
if (textToolInteractiveInputElement) editor.handle.onChangeText(textInputCleanup(textToolInteractiveInputElement.innerText), isLeftOrRightClick);
177177
else viewportPointerInteractionOngoing = isTargetingCanvas instanceof Element;
178178
}
179179

frontend/wasm/src/editor_api.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,8 @@ impl EditorHandle {
433433

434434
/// A text box was committed
435435
#[wasm_bindgen(js_name = onChangeText)]
436-
pub fn on_change_text(&self, new_text: String, is_right_click: bool) -> Result<(), JsValue> {
437-
let message = TextToolMessage::TextChange { new_text, is_right_click };
436+
pub fn on_change_text(&self, new_text: String, is_left_or_right_click: bool) -> Result<(), JsValue> {
437+
let message = TextToolMessage::TextChange { new_text, is_left_or_right_click };
438438
self.dispatch(message);
439439

440440
Ok(())

0 commit comments

Comments
 (0)