@@ -56,7 +56,7 @@ pub enum TextToolMessage {
5656	CommitText , 
5757	EditSelected , 
5858	Interact , 
59- 	TextChange  {  new_text :  String  } , 
59+ 	TextChange  {  new_text :  String ,   is_right_click :   bool  } , 
6060	UpdateBounds  {  new_text :  String  } , 
6161	UpdateOptions ( TextOptionsUpdate ) , 
6262} 
@@ -241,6 +241,19 @@ struct TextToolData {
241241} 
242242
243243impl  TextToolData  { 
244+ 	fn  delete_empty_layer ( & mut  self ,  font_cache :  & FontCache ,  responses :  & mut  VecDeque < Message > )  -> TextToolFsmState  { 
245+ 		// Remove the editable textbox UI first 
246+ 		self . set_editing ( false ,  font_cache,  responses) ; 
247+ 
248+ 		// Delete the empty text layer and update the graph 
249+ 		responses. add ( NodeGraphMessage :: DeleteNodes  { 
250+ 			node_ids :  vec ! [ self . layer. to_node( ) ] , 
251+ 			delete_children :  true , 
252+ 		} ) ; 
253+ 		responses. add ( NodeGraphMessage :: RunDocumentGraph ) ; 
254+ 
255+ 		TextToolFsmState :: Ready 
256+ 	} 
244257	/// Set the editing state of the currently modifying layer 
245258fn  set_editing ( & self ,  editable :  bool ,  font_cache :  & FontCache ,  responses :  & mut  VecDeque < Message > )  { 
246259		if  let  Some ( editing_text)  = self . editing_text . as_ref ( ) . filter ( |_| editable)  { 
@@ -479,32 +492,33 @@ impl Fsm for TextToolFsmState {
479492			} 
480493			( TextToolFsmState :: Editing ,  TextToolMessage :: CommitText )  => { 
481494				if  tool_data. new_text . is_empty ( )  { 
482- 					// Remove the editable textbox UI first 
483- 					tool_data. set_editing ( false ,  font_cache,  responses) ; 
484- 
485- 					// Delete the empty text layer and update the graph 
486- 					responses. add ( NodeGraphMessage :: DeleteNodes  { 
487- 						node_ids :  vec ! [ tool_data. layer. to_node( ) ] , 
488- 						delete_children :  true , 
489- 					} ) ; 
490- 					responses. add ( NodeGraphMessage :: RunDocumentGraph ) ; 
491- 
492- 					return  TextToolFsmState :: Ready ; 
495+ 					return  tool_data. delete_empty_layer ( font_cache,  responses) ; 
493496				} 
494497
495498				responses. add ( FrontendMessage :: TriggerTextCommit ) ; 
496499				TextToolFsmState :: Editing 
497500			} 
498- 			( TextToolFsmState :: Editing ,  TextToolMessage :: TextChange  {  new_text } )  => { 
499- 				tool_data. set_editing ( false ,  font_cache ,  responses ) ; 
501+ 			( TextToolFsmState :: Editing ,  TextToolMessage :: TextChange  {  new_text,  is_right_click  } )  => { 
502+ 				tool_data. new_text  = new_text ; 
500503
501- 				responses. add ( NodeGraphMessage :: SetInput  { 
502- 					input_connector :  InputConnector :: node ( graph_modification_utils:: get_text_id ( tool_data. layer ,  & document. network_interface ) . unwrap ( ) ,  1 ) , 
503- 					input :  NodeInput :: value ( TaggedValue :: String ( new_text) ,  false ) , 
504- 				} ) ; 
505- 				responses. add ( NodeGraphMessage :: RunDocumentGraph ) ; 
504+ 				if  !is_right_click { 
505+ 					tool_data. set_editing ( false ,  font_cache,  responses) ; 
506506
507- 				TextToolFsmState :: Ready 
507+ 					responses. add ( NodeGraphMessage :: SetInput  { 
508+ 						input_connector :  InputConnector :: node ( graph_modification_utils:: get_text_id ( tool_data. layer ,  & document. network_interface ) . unwrap ( ) ,  1 ) , 
509+ 						input :  NodeInput :: value ( TaggedValue :: String ( tool_data. new_text . clone ( ) ) ,  false ) , 
510+ 					} ) ; 
511+ 					responses. add ( NodeGraphMessage :: RunDocumentGraph ) ; 
512+ 
513+ 					TextToolFsmState :: Ready 
514+ 				}  else  { 
515+ 					if  tool_data. new_text . is_empty ( )  { 
516+ 						return  tool_data. delete_empty_layer ( font_cache,  responses) ; 
517+ 					} 
518+ 
519+ 					responses. add ( FrontendMessage :: TriggerTextCommit ) ; 
520+ 					TextToolFsmState :: Editing 
521+ 				} 
508522			} 
509523			( TextToolFsmState :: Editing ,  TextToolMessage :: UpdateBounds  {  new_text } )  => { 
510524				tool_data. new_text  = new_text; 
0 commit comments