How can I programmatically edit a text block

I tried to use:

diagram.toolManager.textEditingTool.textBlock = myTextBlock
diagram.toolManager.textEditingTool.doStart();


It entered the editing mode and I can typed in the characters, however it seems I could not exit the editing mode and the text box is always showing there even though I tried mouse click outside of the text box.


Did I do anything wrong?


Thanks.

Yes, you need to set TextEditingTool.textBlock first, as you have done.
But just calling the doStart method isn’t enough – the TextEditingTool needs to be running.
So instead, set diagram.currentTool = diagram.toolManager.textEditingTool.