B4J Question Undo/Redo by canvas.drawline with UndoManager

Alexander Stolte

Well-Known Member
Licensed User
Hello,

How can i save the state of my Canvas drawing for the Undo and Redo Button with the UndoManager?


i use this code for drawing:
B4X:
Process_Globals
    Private pnl_back As B4XView
    Private cvs_back As B4XCanvas
End Sub

Sub AppStart (Form1 As Form, Args() As String)

cvs_back.Initialize(pnl_back)

End Sub

Sub pnl_back_Touch (Action As Int, X As Float, Y As Float)
    
    Select Action
        Case pnl_back.TOUCH_ACTION_DOWN
            x2 = X
            y2 = Y
        Case pnl_back.TOUCH_ACTION_MOVE
            cvs_back.DrawLine(X, Y, x2, y2, xui.Color_RGB(r,g,b), bright)
            x2 = X
            y2 = Y
            cvs_back.Invalidate
        
    End Select
End Sub
 
Top