We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
2023-02-07 09:34 PM
Hello!
Is there any way to change the drawing order of UI-elements?
I am currently working on a Listbox with OnTabItems. There the OnTabItems need to be initialized before the Listbox, so that they get drawn above the Listbox, in order to be able to see them. But when creating the Listbox I don’t know how many Rows I will have in it. So, in the past I created one OnTabItem per column, before creating the Listbox. Everytime a new Row gets selected, I changed the Data of the OnTabItem according to the TabItem they are placed upon and “SetOnTabItem” moved the Item to the new position.
But now I have a Listbox with strongly heterogenous contents. This makes the process of adjusting the OnTabItem pretty ugly. That’s why I would like every row to have its own set of OnTabItems, so that they don’t have to be adjusted all the time. So, every time a new Row gets created, I create new OnTabItems. But because they get created (and therefore drawn) after the Listbox, you can’t see them.
I tried a few things to change the drawing order, but nothing worked. For example one can change the itemID by calling “DG::Item::Init(const Panel& panel, short item)” or “DG::ItemBase::Set(short panelId, short itemId, bool created)”. But sadly that did not work and had the weird side-effect of loosing the connection between the ListBox in Archicad and the DG::ListBox object.
Thank You for helping me!
2023-02-13 07:29 PM
The drawing order of the controls in a dialog is determined by the operating system, therefore the ontab items must preceede the listbox in the resource.
So your first method of approach is the correct way. Regardless of how many different layouts you have you should place all the ontab items in the resource before the listbox. And then when the listbox row is selected the appropriate ontab items should be filled with the needed content and set on the columns of the listbox row.
You can reuse the same ontab item on more types of rows, or you can add a different ontab item for each type of row (and so have a 'group' of ontab items for each row type). But these need to preceede the listbox.
I hope this helps.
There can be some rare cases for example when the number of columns in the listbox depends on dynamic data and every column needs ontab items. In this case ontab items can not be placed in the resource because we do not know how much will be needed. But when the dialog is opened the column number needs to be determined and the ontab items should be added to the dialog with a listbox following them. This listbox can be used to display the data. The position and size of the listbox can be copied from a placeholder item (like a static text for example) which is placed in the resource (and of course the placeholder item must be hidden).