Ui.undo question

Hi there,

I am exploring the possibilities of ui.undo and found one thing a bit strange.

while this is undoable:

ui.undo.startBlock(‘Undo Parameter Change’)
par.val = 12
ui.undo.endBlock()

this is not:

ui.undo.startBlock(‘Undo Parameter Change’)
par.expr = ‘12 - 2’
ui.undo.endBlock()

I know I can add this behaviour with ui.undo.addCallback(…), but is there a rule which actions need a special callback function and which actions do not?

Best wishes,
David

This system is in ongoing development. There is no simple rule as to which actions currently work and which don’t. For now, you just have to test and write functions for those that don’t.

I’ve put this in the undo todo list.

An interesting workaround I found is that you can perform some action that is undoable, and then perform the non-undoable action, and it will undo.
image

:face_with_monocle: :thinking: :face_with_raised_eyebrow:

Working with this for a while now, I think it is pretty dangerous, that we do not know, which commands have an effect. I would prefer, that only addCallback would work, because we won’t have to think about unwanted side effects of things happen between startBlock and endBlock. With addCallback we can implement any functionality already.

I’m picking up what you’re putting down here. I am going to see what I can do about 1) getting a report on what is inside a block and 2) creating a callbacks-only block.

1 Like

Is there an example somewhere of how to use ui.undo.addCallback()?

Hi @tekt ,
This video from Tim Franklin is a great resource about implementing undo with callbacks: Touchdesigner Tutorial - How To Add Undo Redo To Your UI - YouTube

1 Like