I know that I can implement multiple undo using the TextUndo widget. But that doesn't do the redo function.
How can I implement both multiple undo and multiple redo?
I know that I can implement multiple undo using the TextUndo widget. But that doesn't do the redo function.
How can I implement both multiple undo and multiple redo?
Problem is that the '' binding is assigned twice, for the virtual event '<>' (to implement emacs-like pasting) and to the virtual event '<>'. A normal Tk::Text
does not have the undo functionality, so having the C-y
binding here makes sense. Unfortunately this binding clashes when using a Tk::TextUndo
.
You have the following possibilities:
C-y
binding for <<Paste>>
globally, e.g. by using:
$mw->eventDelete('<<Paste>>', '<Control-Key-y>');
I am not sure how this can be resolved best in the Perl/Tk source itself. Simplest would be to remove the emacs key binding for '<>' here, but then emacs users could be unhappy. I am open to suggestions...
The
text
widget supports a full undo/redo functionality. You just have to turn it on; since not all uses oftext
want that sort of thing, it's off by default. To turn it on, you just need to set the boolean-undo
widget option to true. It's as simple as that (though the way you write it might be a little different in languages other than Tcl, e.g., it'sundo
in Tkinter).However, PerlTk seems to make a confused mess of it all. For some reason, the
Tk::Text
widget doesn't support undo/redo (Why? The machinery is in there, poking through.) and theTk::TextUndo
widget doesn't have the redo capability exposed (Why on earth would that be omitted?) These are all limitations in PerlTk, not Tk itself. In that case, your best bet might be theTk::Text::SuperText
class, though to me that's very odd as it's just doing what I consider to be core Tk functionality.Or maybe it's just the CPAN documentation that's out of date.