i want a widget when opened to be on top of other widgets that may also be opened at the time
how do i know what other widgets may be open in the viewport at a point in time with their z orders to do this
or is this something i will have to track and manage manually
Generally speaking, you will need to track it manually. int++ whenever you add one to the viewport. However:
You may be already aware of this, but if you have a widget in the viewport at zOrder 5 and add another at zOrder 5, the latter will render on top. It’s not uncommon to remove and add a widget just to have it pop on top. Somewhat costly and runs Construct - something to be aware of.
Another way is to use a canvas and treat it as a master widget - a canvas supports zOrder. Instead of adding new widgets to the viewport, you add it to the canvas’s containers. You could expose Named Slots (think of them as of a placeholders), give them a high / specific static zOrder and add widgets to those Named Slots. This will they will always appear in the desired layer (of sorts).
Whether this is applicable depends on the given scenario. The approach may be less than ideal in some cases.