diff --git a/editor/src/messages/input_mapper/input_mappings.rs b/editor/src/messages/input_mapper/input_mappings.rs index 6b81964697..41bf51dfc8 100644 --- a/editor/src/messages/input_mapper/input_mappings.rs +++ b/editor/src/messages/input_mapper/input_mappings.rs @@ -156,6 +156,7 @@ pub fn input_mappings() -> Mapping { // TextToolMessage entry!(KeyUp(MouseLeft); action_dispatch=TextToolMessage::Interact), entry!(KeyDown(Escape); action_dispatch=TextToolMessage::CommitText), + entry!(KeyUp(MouseRight); action_dispatch=TextToolMessage::CommitText), entry!(KeyDown(Enter); modifiers=[Accel], action_dispatch=TextToolMessage::CommitText), // // GradientToolMessage diff --git a/editor/src/messages/tool/tool_messages/text_tool.rs b/editor/src/messages/tool/tool_messages/text_tool.rs index 42709be276..449f7e8e4b 100644 --- a/editor/src/messages/tool/tool_messages/text_tool.rs +++ b/editor/src/messages/tool/tool_messages/text_tool.rs @@ -462,8 +462,21 @@ impl Fsm for TextToolFsmState { TextToolFsmState::Ready } (TextToolFsmState::Editing, TextToolMessage::CommitText) => { - responses.add(FrontendMessage::TriggerTextCommit); + if tool_data.new_text.is_empty() { + // Remove the editable textbox UI first + tool_data.set_editing(false, font_cache, responses); + + // Delete the empty text layer and update the graph + responses.add(NodeGraphMessage::DeleteNodes { + node_ids: vec![tool_data.layer.to_node()], + delete_children: true, + }); + responses.add(NodeGraphMessage::RunDocumentGraph); + return TextToolFsmState::Ready; + } + + responses.add(FrontendMessage::TriggerTextCommit); TextToolFsmState::Editing } (TextToolFsmState::Editing, TextToolMessage::TextChange { new_text }) => {