Scrollbar Example

Now we will look at a similar undo example using a Scrollbar.

Edit Scrollbar Script

Set Scrollbar Script

Set the script of the scrollbar to the following RevTalk code. This code is similar to the field code except that the memento is stored on mouseDown and an Undo Action is added (if necessary) on mouseUp.

local sMementoA

on mouseDown pMouseBtnNum

if pMouseBtnNum is 1 then

## Store position of scrollbar so we can undo changes the

## user makes. No undo entry is made here however

## as the user hasn't made any changes yet.

put the long id of the target into sMementoA["scrollbar"]

put the thumbposition of the target into sMementoA["thumbposition"]

end if

end mouseDown

on mouseUp pMouseBtnNum

if pMouseBtnNum is 1 then

## If the position of scrollbar has changed since the mouseDown

## message was received then add an undo action to the queue

if the thumbposition of the target is not sMementoA["thumbposition"] then

undoStoreUndo "change scrollbar position", "Change Scrollbar", sMementoA

end if

## Clear memory

put empty into sMementoA

end if

end mouseUp

Switch to Browse Tool

Change Position of Scrollbar Slider

Click 'Undo Last Change'

The scrollbar slider returns to the original position and a dialog appears.

Click 'Redo Last Change'

The slider goes back to the new position you set and a dialog appears.


Add your comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.