I have added a text block to the group and it is editable. While editing that text the old text which I am editing is still showing up in the background and both texts are overlapping.
also getting following error “ERROR DOMException: Failed to execute ‘removeChild’ on ‘Node’: The node to be removed is not a child of this node.”
while trying to stop the edit of the text if not valid by overriding errorFunction
textEditTool.doCancel();
textEditTool.doDeactivate();
The TextEditingTool does not modify the edited TextBlock until the user finishes the tool successfully. Did you want to make the text editor larger so that it obscures the TextBlock? Or do you want to change the TextBlock.opacity to 0.0 during the operation of the TextEditingTool? Or perhaps some other solution?
No, I was trying to say and what the Tool Lifecycle diagram was trying to show is that if you are cancelling the operation of the tool, you do not need to call anything else besides doCancel. doDeactivate and doStop are called automatically for you no matter how the tool stops.
Try these overrides of TextEditingTool.doActivate and TextEditingTool.doDeactivate:
Yes doCancel and doDeactivate will be triggered automatically but I wanted to override errorFunction so that I can stop the edit and can revert the text to old stage and not update the text to an invalid text.
Hence I was using the doCancel and doDeactivate so that is not done.
Also if I want to inject some of my service that will be triggered on errorFunction like show custom notification on error how to do that?
In the process of accepting any text edit (in the implementation of TextEditingTool.acceptText), it first validates the text. If the call to TextEditingTool.isValidText returns false, it calls the TextBlock.errorFunction (if non-null). Then it calls HTMLInfo.show on the TextEditingTool.currentTextEditor and returns without having accepted the text edit. I don’t see any problem with your showing some error information in your implementation of the errorFunction, although of course the details of how you do that depends entirely on the environment you have on the page.
Regarding your override of doActivate: that’s odd – I just tried it in a copy of the minimal.html sample, and it worked well.
I meant why can’t we use toolManager.textEditingTool for same?
I also want to give a text in the textBlock dynamically but right now when I create a node the default text is the same. How can I give dynamic custom text to the text block’s.
For your last question – isn’t there a Binding on the TextBlock.text property? So you could set the string in the new node data object. And if you expect users to edit the text, you probably want to make the Binding TwoWay.
and when part is created at that time also I am assigning the value for it but it is not getting reflected
e.subject.groupName = “Group” + someIteratingvalue;