I created a custom view ImageButton and added several ImageButton in Pane that will work properly.
In the class module of the custom view, mBase is defined as B4xView.
But cannot be traversed in auto scaling code. runtime throws error.
The traversal code is as follows:
The error thrown is as follows:
It seems that B4xView and ImageButton cannot convert to each other.
In the class module of the custom view, mBase is defined as B4xView.
But cannot be traversed in auto scaling code. runtime throws error.
The traversal code is as follows:
B4X:
Private Sub B4XPage_Appear
For Each n As B4XView In Root.As(Pane)
n.Height=n.Height*Scale
n.Top=n.Top*Scale
n.Left=n.Left*Scale
If n Is MenuBar Then
n.TextSize=n.TextSize*Scale
End If
Next
For Each n1 As ImageButton In Pane1
n1.TextSize=n.TextSize*Scale
n1.Width=n.Width*Scale
n1.Height=n.Height*Scale
Next
End Sub
The error thrown is as follows:
B4X:
Error occurred on line: 53 (B4XMainPage)
java.lang.ClassCastException: class anywheresoftware.b4j.objects.PaneWrapper$ConcretePaneWrapper$NonResizePane cannot be cast to class b4j.example.imagebutton (anywheresoftware.b4j.objects.PaneWrapper$ConcretePaneWrapper$NonResizePane and b4j.example.imagebutton are in unnamed module of loader 'app')
at b4j.example.b4xmainpage._b4xpage_appear(b4xmainpage.java:96)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:629)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at jdk.internal.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:513)
at anywheresoftware.b4a.keywords.Common.access$0(Common.java:493)
at anywheresoftware.b4a.keywords.Common$CallSubDelayedHelper.run(Common.java:567)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:832)
It seems that B4xView and ImageButton cannot convert to each other.