Jump to content
Developer Wiki and Function Reference Links Read more... ×
Cmb

How to group Undo Events ?

Recommended Posts

Hi,

 

I am struggling with a specific case that was working fine in VectorScript, but not with the SDK.

 

Basically, I have a PIO which is creating multiple objects as kids with CreateCustomObject(), + changing one of its parameter with setParamString. This is triggered from a button in its pane.

The expected behavior is to undo all of this with CTRL+Z. But I have to press CTRL+Z a first time and that will cancel the objects creation, and then CTRL+Z a second time to get the changed parameter back.

It's not the case in VectorScript with pretty much the same code. I tried to use the Undo Events primitives of the SDK but don't achieved what I wanted, maybe I was doing it wrong.

 

Is there a way to group these undo 'events' together ?

 

Thanks,

Share this post


Link to post

SetUndoMethod() begins an undo event and EndUndo() ends it. 

 

Many VW actions already have associated undo events, for example the reset event or a widget change will already start and end undo. In those cases, you only need to add objects to the undo table (the various add swap commands) of any action that modifies the drawing outside of the object being edited. 

Share this post


Link to post

So regarding this specific case, my problem was relative to 

VCOMImpl<IProviderShapePane> ::OnWidgetChange(SShapePaneWidgetOnWidgetChange& data, bool& outNeedReset)

I realised that outNeedReset beeing "true" was the cause of  a second separated Undo event. Setting this boolean to "false" and doing the reset of the object myself permitted to Undo all I wanted with only one CTRL+Z.

For other cases I used the various swap commands as you told me and it worked.

Thank you

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×