Hi,
how can I realize an UNDO Function for my drawn Canvas?
Here is my Examplecode, I don't know what to do...
how can I realize an UNDO Function for my drawn Canvas?
Here is my Examplecode, I don't know what to do...
B4X:
Sub Globals
Dim c As Canvas
Dim b As Bitmap
Private ImageView1 As ImageView
Dim r As Reflector
Private Button1 As Button
Dim undo As List
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Main")
b.Initialize(File.DirAssets, "pic1.png")
c.Initialize(ImageView1)
ImageView1.Invalidate
r.Target = ImageView1
r.SetOnTouchListener("img_touch")
undo.Initialize
undo.Add(ImageView1)
End Sub
Sub img_touch(viewtag As Object, action As Int, X As Float, Y As Float, motionevent As Object) As Boolean
undo.Add(ImageView1)
c.DrawCircle(X,Y,5dip,Colors.Red,True,1dip)
ImageView1.Invalidate
End Sub
Sub Button1_Click
ImageView1 = undo.Get(undo.Size-1)
undo.RemoveAt(undo.Size-1)
ImageView1.Invalidate
End Sub