Page Index Toggle Pages: 1 [2]  Send TopicPrint
Hot Topic (More than 10 Replies) Undo & Redo ! (Read 5963 times)
Kannan Thirumal
Senior Member
****
Offline


I Love Mind Fusion Diagram
:-)

Posts: 270
Location: Bangalore, India
Joined: Jan 18th, 2019
Re: Undo & Redo !
Reply #15 - Aug 27th, 2020 at 11:04am
Print Post  
Hi,

We have a align behavior in our diagram. We align all the selected elements in the diagram on click of a button using the below code. The diagram elements are getting aligned but nothing is added to undoManager.undoHistory. May I know how to solve this issue?

  private alignLeft() {

    var itemsToBeAligned = this.diagram.getNodes().filter(x => x.getSelected() === true);

    if (this.selectedNode) {
      var left = this.selectedNode.getBounds().left();

      itemsToBeAligned.forEach(f => {
        if (f != this.selectedNode) {
          let bounds: Rect = f.getBounds();
          var x = left;
          var y = bounds.y;
          f.setBounds(new Rect(x, y, bounds.width, bounds.height), true);
        }
      });

      this.updateLinks(itemsToBeAligned);
    }
  }

Regards,
Kannan
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Undo & Redo !
Reply #16 - Aug 27th, 2020 at 1:35pm
Print Post  
Hi,

Try this -

Code
Select All
diagram.startCompositeOperation();

for (var i = 0, l = diagram.items.length; i < l; i++)
{
    var command = new ChangeItemCommand(diagram, diagram.items[i]);
    diagram.executeCommand(command);
}

// align items here
// ...

diagram.commitCompositeOperation(); 



Regards,
Slavcho
  
Back to top
 
IP Logged
 
Kannan Thirumal
Senior Member
****
Offline


I Love Mind Fusion Diagram
:-)

Posts: 270
Location: Bangalore, India
Joined: Jan 18th, 2019
Re: Undo & Redo !
Reply #17 - Sep 4th, 2020 at 4:17am
Print Post  
This works as desired. Thank you Slavcho  Smiley
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1 [2] 
Send TopicPrint