Replies: 2 comments
-
I think this is related to this issue. I worked around this, by changing |
Beta Was this translation helpful? Give feedback.
0 replies
-
Ah true, that issue looks related! Hmm ok maybe I can work around it with your suggestion indeed 🤔 Though it feels very ugly and inefficient to have a lot of hidden components... Thanks for your hint 👍 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Consider this Slint code (open in SlintPad):
A click on the button causes the the first model value changing to
true
, which in turn will enable the conditionalComboBox
. So far so good, this works as expected. However, when clicking the button again (which actually does not modify the model value anymore), theComboBox
component is re-created. You can see it that the previously selected combobox item is discarded, i.e.current-index
is reset to 0. And in the console we can see the "init" message appearing with each click.Unfortunately this behavior is a big problem for the LibrePCB project. So I wonder, is this expected behavior or is it considered a bug?
The example above is just a MWE for showing the problem. Our real use-case is the following:
The toolbar in the editor depends on the active tool. And the active tool is part of a tab from a model of tabs. In simplified form:
Now, the C++ backend calls
set_row_data()
on the tabs model every time any data of the tab changes, to update the UI. If the current tool changed, it will cause some toolbar to hide and another one to appear. But if the tool didn't change, it will still re-initialize the current toolbar, causing any user input to be discarded, focus problems, and even some flickering of the cursor.Now I'm struggling how to fix this problem. If this is considered a bug which will be fixed, I'm happy as my approach should work then. Otherwise I'd be happy to get some advice how to implement my use-case with persistent conditional components.
(note that
tool: EditorTool
cannot be moved out of the model as a standalone property, because actually even the wholeTabData
model is just part of an outer model, i.e. there can be multiple active tools at the same time)Thanks
Beta Was this translation helpful? Give feedback.
All reactions