Get Shape's actual size during a PartResized event

I’m trying to capture the width and height, or desiredSize of a shape after it’s resized. For example, if when creating my node I set its width and height to 100 each, then I try to resize the shape to 200x200 and look at the shape’s desiredsize in my PartResized event function, I’ll get 100x100 instead of 200x200. Then if I try to resize it to 300x300, the PartResized function will return 200x200. Its as if the PartResized function is called before the shape’s new size is actually saved.

Is there anyway around this? It would be great to constantly poll the shapes new size during and even before the user lets go of the mouse button to end a resize event.

Thanks!

Can I see the code? Are you sure you’re looking at the part.resizeObject ?

Have you set Part.resizeObjectName to refer to the object that you want the user to resize?

I just tried this:

      $(go.Diagram, "myDiagramDiv",
          { . . .,
            "PartResized": function(e) {
              var obj = e.subject;
              console.log(obj.desiredSize.toString());
            },
            . . . })

and it behaved exactly as expected – at the end of the resize the Part.resizeObject had the expected GraphObject.desiredSize.

If you want to track the size during the resize you’ll have to customize the ResizingTool, because the “PartResized” DiagramEvent only happens after the resizing has finished.

Walter, thank you that did the trick.

I was using the “PartResized” DiagramEvent.

Actually, this might be a different way of setting the same event function?

I think my problem was I wasn’t using the “subject” property of event (e) object.

Yes, when using go.GraphObject.make to initialize a Diagram, specifying the “PartResized” property is the same as calling Diagram.addDiagramListener.