startGroupAction / closeGroupAction within my textChange handler, but that does not appear to group the actual text change with my custom change.
function nodeTextChange(args) {
...
diagram.model.historyManager.startGroupAction();
var entry = { prevName: node.addInfo.Name, object: node };
diagram.model.historyManager.push(entry);
node.addInfo.Name = args.value;
diagram.model.historyManager.closeGroupAction();
}
Any suggestions ?
Thanks
Jim
Hi Shyam,
The suggested approach seems to be working - with a few challenges.
For example if I issue startGroupAction in the double-click event and the user does not change the text - simply clicks outside of the shape - then I never reach the closeGroupAction statement.
This can result in the "group" becoming much larger than expected.
Another scenario: When a shape is dragged from the palette, the dragEnter event is fired which sets the width and height of the shape as well as its pathData. I issue a startGroupAction in this event. Additional addInfo properties are subsequently set in the drop handler as well as the nodecollectionchange event handler. I actually put the closeGroupAction statement in an event that fires after the node is registered in the database and I have a key value that I add to an addInfo property of the node.
Since the node is put in edit mode after being dropped, I'd really like to wait to issue the closeGroupAction after the text has changed, but once again, the user may elect not to enter any text at this point.
Any suggestions for handling this situation. Is there any event fired if the user does not change/enter any text by simply clicking outside the node? Is there an event fired when I enter edit mode after the node is dropped?
Thanks for any advice on how to deal with my challenge.
Jim
Query |
Response |
Is there any event fired if the user does not change/enter any text by simply clicking outside the node? |
Code example:
//define click event
Diagram1.OnClientClick = "click";
//define editorfocuschange
Diagram1.OnClientEditorFocusChange = "editorFocussed";
var groupEnable = false;
function editorFocussed(evt) {
var diagram = $("#diagram").ejDiagram("instance");
diagram.model.historyManager.startGroupAction();
groupEnable = true;
}
function click(args) {
var diagram = $("#diagram").ejDiagram("instance");
if (groupEnable) {
diagram.model.historyManager.closeGroupAction();
groupEnable = false;
}
}
|
Is there an event fired when I enter edit mode after the node is dropped? |
Please use OnClientEditorFocusChange event which triggers when the label is in edit Mode. Please refer to the code example in the above column.
|
Hi Shyam,
I have made some progress using startGroupAction / closeGroupAction, but I'm still encountering problems.
Watch the attached video.
If I drag a shape onto the canvas, I issue startGroupAction in the dragEnter event. So far so good.
However, if after entering text in this newly dropped shape, I go and drag another shape (which is what our users will do), I force a closeGroupAction in the dragEnter event if groupEnable is true (which it will be in this scenario).
This seems to mess things up, since the drop of the initial shape including its changed text is not contained within a single "group". I end up having to click multiple times on Undo to back out the text and the drop of the shape itself - what I'm trying to avoid.
Look at the console in the video and you'll see the order in which things are happening.
Any suggestions on how to fix this, so that each dropped shape including the text entered when it's dropped are contained in a single group?
Thanks
Jim
Hi again,
Here's a simple video showing things working as I'd like.
I drop a shape, add the text and then click anywhere on white space. As you can see, I only have to click on Undo once to remove the node and the text. In the previous video, clicking once would undo the text change, and then a second click was required to undo the drop of the shape.
Hope you can provide me with a technique to help me get past this hurdle.
Thanks
Jim
Hi Shyam,
Thanks for the additional advice.
I have made progress and things are working much better.
Who would have thought that Undo/Redo would have been such a big challenge.
Jim