Adding Undo functionality to widgets?

45 views
Skip to first unread message

Tiddly Novice

unread,
Dec 4, 2020, 8:57:58 PM12/4/20
to TiddlyWiki
The checkbox, the select, and probably other seemingly simple widgets don't possess undo functionality. I'm kinda taken aback by this since my previous gui dev training was in Visual Basic, where I pretty much took for granted that it was easy to arrange for the undo functionality to be available to just about all parts of the gui.

Why isn't there undo/redo functionality for so many widgets and stuff in TW? Am I simply not setting up my widgets right?

Eric Shulman

unread,
Dec 4, 2020, 9:41:58 PM12/4/20
to TiddlyWiki
On Friday, December 4, 2020 at 5:57:58 PM UTC-8 Tiddly Novice wrote:
The checkbox, the select, and probably other seemingly simple widgets don't possess undo functionality.

The reason these widgets don't have undo functionality is because, while these are "seemingly simple" widgets, depending upon how they are being used they can actually be quite complex in their actions.  These actions can potentially modify several different fields (and possibly several different tiddlers) at once.... and modifying any tiddler fields will have the immediate effect of triggering system-wide "refresh" handling that can radically change the display, including the widgets that triggered the refresh in the first place.

Then there is the question of how many sets of actions you might need to undo.  Should it only be the very last set of actions triggered by the most recent interaction, or should you keep a "stack" of actions so you can back out of multiple interactions, possibly all the way back to when the document was loaded (or at least back to the last time it was saved during the current session).

In the TiddlyWiki Classic days, I implemented a general-purpose *experimental* UndoPlugin (http://tiddlytools.com/#UndoPlugin) that hooked into the TWCore code and kept a global "history stack" of changed tiddlers, so that at any time, you could undo one or more changes, in reverse order, by overwriting the current tiddler definitions with their previous contents.  However, this approach was both compute and storage intensive, and was of limited usefulness in the long run, due to the "framing" problem: for any given user interaction, there could be multiple tiddlers that are added to the "history stack"... and when you trigger the undo command, these changes should be reverted as a single action, even though they comprise multiple entries in the stack.

Perhaps it would be possible to implement something similar for modern TW5, but I suspect it's not really worth the trouble.  In general, for the "simple" undo case, it's usually just as effective to ensure that a given interaction has an "equal and opposite" interaction that the user can perform, rather than some kind of generalized "undo" command.  Thus, if you check a checkbox, you can manually un-check it... if you select from a list, you can change the selection, etc.

-e

TW Tones

unread,
Dec 4, 2020, 10:40:09 PM12/4/20
to TiddlyWiki
TiddlyNovice

I echo Eric's wise words,. however I would ask you to consider what you may be asking for. 
  • Do you want the user (which may be you) to revert something which you may have done by mistake?
  • Is it while coding, or editing tiddlers?
  • Or after selecting or entering a value, using a checkbox or a radio button.
  • Noteself stores all versions, the trashbin plugin allows you to restore deleted tiddlers .
  • Any button or action you craft can be designed to either store the last value and provide a reset, or log each value and allow to to restore from the history.
    • Such histories could be all values use in a given fieldname or only those used a particular tiddlers fieldname.
  • I myself are working on a MRU "Most Recently Used"  function which stores each value given to a field, and lists them in the reverse order used, so you can easily enter values previously entered.
Remember Visual Basic is a programming language and development environment (SDK) that makes software, TiddlyWiki has a language, is a development environment and the software, including the SDK

You can do what ever you please, in TiddlyWiki.

Tones
Reply all
Reply to author
Forward
0 new messages