Skip to content

Commit

Permalink
Make the Text tool delete empty text layers when clicking away wth LMB (
Browse files Browse the repository at this point in the history
  • Loading branch information
mTvare6 authored Jan 13, 2025
1 parent 3582126 commit d692538
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions editor/src/messages/tool/tool_messages/text_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub enum TextToolMessage {
Interact,
PointerMove { center: Key, lock_ratio: Key },
PointerOutsideViewport { center: Key, lock_ratio: Key },
TextChange { new_text: String, is_right_click: bool },
TextChange { new_text: String, is_left_or_right_click: bool },
UpdateBounds { new_text: String },
UpdateOptions(TextOptionsUpdate),
}
Expand Down Expand Up @@ -577,10 +577,10 @@ impl Fsm for TextToolFsmState {
responses.add(FrontendMessage::TriggerTextCommit);
TextToolFsmState::Editing
}
(TextToolFsmState::Editing, TextToolMessage::TextChange { new_text, is_right_click }) => {
(TextToolFsmState::Editing, TextToolMessage::TextChange { new_text, is_left_or_right_click }) => {
tool_data.new_text = new_text;

if !is_right_click {
if !is_left_or_right_click {
tool_data.set_editing(false, font_cache, responses);

responses.add(NodeGraphMessage::SetInput {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/io-managers/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ export function createInputManager(editor: Editor, dialog: DialogState, portfoli
}

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

Expand Down
4 changes: 2 additions & 2 deletions frontend/wasm/src/editor_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,8 @@ impl EditorHandle {

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

Ok(())
Expand Down

0 comments on commit d692538

Please sign in to comment.