Jump to content
Developer Wiki and Function Reference Links ×

How to group Undo Events ?


Cmb

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,

Link to comment

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. 

Link to comment

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

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...