I was looking for a way to change the z-order of UI controls in a window but couldn’t find anything definitive. Here’s an example of how it can be done if anyone is still looking for a solution:
- Add three rectangles, maybe coloured white, red & blue, created in that order so the white is at back and blue at front. Make them overlap so you can see the change.
- Add a button to change order when pressed
- Add the following in the button’s ‘Pressed’ event. This should re-order the three rectangles so the white rectangle is at front. Sorry, I still haven’t worked out how to paste code in here
var arrayRects() As DesktopRectangle
System.DebugLog(“— order before changes —”)
for each obj as Object in self.Controls
if obj IsA DesktopRectangle then
var strName As String = DesktopRectangle(obj).Name
System.DebugLog(strName)
arrayRects.Add(DesktopRectangle(obj)) // adding this rectangle to the array
end if
next
// removing all rectangles from window
for index as Integer = 0 to arrayRects.LastIndex
arrayRects(index).Close
next
// adding rectangles back to window in new order
self.AddControl(arrayRects(1))
self.AddControl(arrayRects(2))
self.AddControl(arrayRects(0))
System.DebugLog(“— order after changes —”)
for each obj as Object in self.Controls
if obj IsA DesktopRectangle then
var strName As String = DesktopRectangle(obj).Name
System.DebugLog(strName)
end if
next
4 posts - 4 participants