Scroll to navigation

Prima::Widget::UndoActions(3) User Contributed Perl Documentation Prima::Widget::UndoActions(3)

NAME

Prima::Widget::UndoActions - undo and redo the content of editable widgets

DESCRIPTION

Generic helpers that implement stored actions for undo/redo.

SYNOPSIS

        package MyUndoableWidget;
        use base qw(Prima::Widget Prima::Widget::UndoActions);
        sub on_mousedown
        {
                if ( $button == mb::Left ) {
                        $self->begin_undo_group;
                        $self->push_undo_action(text => $self->text);
                        $self->text($self->text . '.');
                        $self->end_undo_group;
                } else {
                        $self->undo; # will call $self->text( old text )
                }
        }

Properties

Sets the limit on the number of atomic undo operations. If 0, undo is disabled.

Methods

Opens a bracket for a group of actions that can be undone as a single operation. The bracket is closed by calling "end_undo_group".
Return a boolean flag that reflects if the undo or redo actions could be done. Useful for graying a menu, f ex.
Closes the bracket for a group of actions, that was previously opened by "begin_undo_group".
Should be called once, inside init()
Checks whether there are any undo-able ACTIONs in the undo list.
Stores a single undo action where ACTION is a method to be called inside undo/redo, if any. Each action is added to the last undo group and will be removed/replayed together with the other actions in the group.
Stores a single undo action where ACTION is the method to be called inside undo/redo, if any. Each action is a single undo/redo operation.
Re-applies changes, previously rolled back by "undo".
Rolls back changes into an internal array. The array size cannot extend the "undoLimit" value. In case "undoLimit" is 0 no undo actions can be made.

AUTHOR

Dmitry Karasik, <dmitry@karasik.eu.org>.

SEE ALSO

Prima, Prima::Edit,

2024-02-01 perl v5.38.2