You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is simple, but has the drawback, that you have to declare the widgets in a chaotic order.
lxn/walk uses a simple trick here in it's declarative package:
You can assign each widget to a pointer, and use this later as a reference.
If we implement something like that in duit, it would look like:
varlabel**duit.Labelduit.Top.UI=&duit.Box{
...Kids: duit.NewKids(
&duit.Label{ // we declare the widget in it's usual placeTarget: &label, // This get's evaluated later.
},
& duit.Button{
// here we can use the label pointer in the callback.
},
}
The needed change would be, that each UI element, needs a Target as a pointer to itself.
The variables holding the pointer, have to be assigned when building the Top.UI.
I don't know if we need to add another function for this, or use dui.Render.
Each widget would check it's Target field and if it is not nil, set the pointer to itself.
What do you think? Is it worth it?
The text was updated successfully, but these errors were encountered:
This allows to define widgets inside the main UI in the
natural order.
Widgets that are referenced from other widgets can do so
by Target pointers.
This is an example implementation for mjl-/duit#9
I implemented this for some widgets as an example in the fork ktye/duit in ktye/duit@164b760
The assignments take place within the widget's Layout method.
As I understand, all widgets that should be referenced in another one, e.g. to change the text of a label, have to be declared upfront:
further down, the UI is declared in a nested structure:
This is simple, but has the drawback, that you have to declare the widgets in a chaotic order.
lxn/walk uses a simple trick here in it's declarative package:
You can assign each widget to a pointer, and use this later as a reference.
If we implement something like that in duit, it would look like:
The needed change would be, that each UI element, needs a Target as a pointer to itself.
The variables holding the pointer, have to be assigned when building the Top.UI.
I don't know if we need to add another function for this, or use
dui.Render
.Each widget would check it's Target field and if it is not nil, set the pointer to itself.
What do you think? Is it worth it?
The text was updated successfully, but these errors were encountered: