Tabbed pane child element visibility/position weirdness?
Posted: Thu Mar 19, 2020 1:49 pm
Can't work out what I'm missing or doing wrong. I feel like this is something I'm not understanding rather than a bug.
I'm trying to replicate a crafting grid menu search function. (I know that I could be using something like an elem-chooser to get the base game one, so you don't need to tell me - just assume for now that I don't want to use that for valid reasons). However the following could have any application, it doesn't have to be about replicating any existing gui, it could be tabbed panes of something completely original.
Tabbed panes are structured as an array of "tabs", each of which is a table of tables representing the tab's properties and the content elements. So it's surprisingly easy to filter out particular child elements on the on_gui_text_changed event. If the child elements are themselves children of a table, you just make each of them visible or non-visible on some match against the filter text, and the tables automatically realign themselves:
However, if you do this to all the tabs at once (including the unselected tabs), and then switch to a different tab, the child elements in the other tabs have been hidden but their position has not "re-flowed":
Changing the text field again while the tab is selected causes them to reflow correctly:
To work around this, you can run the filtering every time a tab pane is clicked. However, there are two big drawbacks to that:
1. You occasionally see a flicker of the unfiltered tab content for an instant, presumably because the game renders the unfiltered tab content first and then processes the custom gui click event in the next tick.
2. It would be much preferred to filter all the tabs at once, because the next step is to disable any tab that now has zero visible elements in it, so I have to run through them all on a textfield change anyway.
Anyone run into this kind of thing?
I'm trying to replicate a crafting grid menu search function. (I know that I could be using something like an elem-chooser to get the base game one, so you don't need to tell me - just assume for now that I don't want to use that for valid reasons). However the following could have any application, it doesn't have to be about replicating any existing gui, it could be tabbed panes of something completely original.
Tabbed panes are structured as an array of "tabs", each of which is a table of tables representing the tab's properties and the content elements. So it's surprisingly easy to filter out particular child elements on the on_gui_text_changed event. If the child elements are themselves children of a table, you just make each of them visible or non-visible on some match against the filter text, and the tables automatically realign themselves:
However, if you do this to all the tabs at once (including the unselected tabs), and then switch to a different tab, the child elements in the other tabs have been hidden but their position has not "re-flowed":
Changing the text field again while the tab is selected causes them to reflow correctly:
To work around this, you can run the filtering every time a tab pane is clicked. However, there are two big drawbacks to that:
1. You occasionally see a flicker of the unfiltered tab content for an instant, presumably because the game renders the unfiltered tab content first and then processes the custom gui click event in the next tick.
2. It would be much preferred to filter all the tabs at once, because the next step is to disable any tab that now has zero visible elements in it, so I have to run through them all on a textfield change anyway.
Anyone run into this kind of thing?