Hi
My first post...
Seemed to have solved all other issues, but hopefully someone can help with htis one regarding undo manager class from Erel.
Background, the app has (at present) 6 buttons, that are basically counters. UndoManager has been working fine, with the buttons declared as buttons. However i have change the buttons to an array so i can manage the code better elsewhere and give me flexibilty to add more buttons easily.
I now get and error when getState is called to read the button settings.
I can see the error says "This method does not support arrays of primitives." is thier a way round this or solution???
Thanks in advance
steve
This is the error, line 2 in add state is where it errors
*** mainpage: B4XPage_Disappear [mainpage]
*** catchtrack: B4XPage_Appear [mainpage]
Error occurred on line: 15 (UndoManager)
java.lang.RuntimeException: java.lang.RuntimeException: This method does not support arrays of primitives.
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.writeType(B4XSerializator.java:285)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.writeObject(B4XSerializator.java:241)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.WriteObject(B4XSerializator.java:121)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.ConvertObjectToBytes(B4XSerializator.java:79)
My first post...
Seemed to have solved all other issues, but hopefully someone can help with htis one regarding undo manager class from Erel.
Background, the app has (at present) 6 buttons, that are basically counters. UndoManager has been working fine, with the buttons declared as buttons. However i have change the buttons to an array so i can manage the code better elsewhere and give me flexibilty to add more buttons easily.
I now get and error when getState is called to read the button settings.
I can see the error says "This method does not support arrays of primitives." is thier a way round this or solution???
Thanks in advance
steve
This is the error, line 2 in add state is where it errors
*** mainpage: B4XPage_Disappear [mainpage]
*** catchtrack: B4XPage_Appear [mainpage]
Error occurred on line: 15 (UndoManager)
java.lang.RuntimeException: java.lang.RuntimeException: This method does not support arrays of primitives.
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.writeType(B4XSerializator.java:285)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.writeObject(B4XSerializator.java:241)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.WriteObject(B4XSerializator.java:121)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.ConvertObjectToBytes(B4XSerializator.java:79)
getState with the button array:
Sub GetState As UndoData
Dim ud As UndoData
ud.Initialize
For i = 1 To 6
ud.Net_txt(i) = btnNet(i).Text
ud.Net_sz(i) = btnNet(i).TextSize
ud.Net_clr(i) = btnNet(i).TextColor
ud.Net_count(i) = Ncount(i)
Next
ud.TotalCount = TotalCount
ud.TotalC_sz = btnTotalC.TextSize
ud.TotalC_clr = btnTotalC.TextColor
Return ud
End Sub
addstate in undomanager:
Public Sub AddState (state As Object)
Dim b() As Byte = ser.ConvertObjectToBytes(state)
If DifferentThanPrevState(b) Then
If index < stack.Size - 1 Then
'this happens when a new state is added after one or more undo actions.
For i = stack.Size - 1 To index + 1 Step - 1
stack.RemoveAt(i)
Next
End If
stack.Add(b)
If stack.Size >= MAX_STACK_SIZE Then
stack.RemoveAt(1) 'keep the initial state
End If
index = stack.Size - 1
End If
Log($"Stack size: ${stack.Size}"$)
End Sub