Previously, when I was using BevelButton, this code used to work:
Var newPBB As BevelButton
newPBB = New PaperBevelButton //this is a control set of type BevelButton
newPBB.Top = PaperBevelButton(index-1).Top + RowHeight
However, since changing everything to use the new API 2 DesktopUIControls, the equivalent code throws an IllegalCastException on line 2
Var newPBB As DesktopBevelButton
newPBB = New PaperBevelButton //super of this control set is now DesktopBevelButton, throws exception
newPBB.Top = PaperBevelButton(index-1).Top + RowHeight
The message of the exception is
MAK95Window.MAK95Window cannot be cast to PaperAnalysisListboxCanvasContainer.PaperAnalysisListboxCanvasContainer
PaperBevelButton is a child of PaperAnalysisListboxCanvasContainer which is a child of the window MAK95Window. So I am very confused as to what is happening…
Is it still possible to dynamically create new members of a control set at runtime in API 2? I read a recent blog post saying that there is a new way of adding controls, AddControl.
https://blog.xojo.com/2022/01/07/desktop-adding-controls-at-runtime/
However, I can’t find any information on how to implement AddControl
DesktopWindow.AddControl
From Xojo Documentation
Method
DesktopWindow.AddControl(control as DesktopUIControl)
New in 2021r3
Supported for all project types and targets.
Adds the control passed to the layout.
The LR on Desktop Control Sets seems to suggest that control sets should still work with the new DesktopUIControls.
https://documentation.xojo.com/topics/user_interface/desktop/desktop_controls/control_sets.html
Would anyone know the correct method to use?
Thanks,
Frank