Closed TheRiceCold closed 3 months ago
hmmm I just managed to reproduce it with just lables, so it might not be specific to Boxes...
const stack = Widget.Stack({
children: {
'child1': Widget.Label('first child'),
'child2': Widget.Label('second child'),
},
shown: 'child2', // it shows the first child...
})
Using a variable works as expected though
const shownVariable = Variable('child2');
const stack = Widget.Stack({
children: {
'child1': Widget.Label('first child'),
'child2': Widget.Label('second child'),
},
shown: shownVariable.bind(), // it shows the second child
})
the gobject constructor might run the shown setter before the children, in which case setting it statically doesn't work
but I feel the shown
property is usully bound to something, similar to visible
, so this can be safely ignored, maybe its worth a mention on the wiki
If you want to set the shown property statically anyway, you might have luck setting it in the setup method, which should be the last thing executed. Didn't try this though.
const stack = Widget.Stack({
children: {
'child1': Widget.Label('first child'),
'child2': Widget.Label('second child'),
},
setup: self => {
self.shown = 'child2'
}
})
I expect the child1(Label) to show up first without using shown
statically or dynamically, but it always shows the child2(Box) first so I what I did is change child2 to EventBox and it worked.
Widget.Stack({
children: {
'child1': Widget.Label('first child'),
'child2': Widget.EventBox({ }), // does not force itself to show up first unlike box widget
}
})
If you want to set the shown property statically anyway, you might have luck setting it in the setup method, which should be the last thing executed. Didn't try this though.
const stack = Widget.Stack({ children: { 'child1': Widget.Label('first child'), 'child2': Widget.Label('second child'), }, setup: self => { self.shown = 'child2' } })
I've tried that but the box(child2) still forces itself to show up first.
hmmm I just managed to reproduce it with just lables, so it might not be specific to Boxes...
const stack = Widget.Stack({ children: { 'child1': Widget.Label('first child'), 'child2': Widget.Label('second child'), }, shown: 'child2', // it shows the first child... })
Using a variable works as expected though
const shownVariable = Variable('child2'); const stack = Widget.Stack({ children: { 'child1': Widget.Label('first child'), 'child2': Widget.Label('second child'), }, shown: shownVariable.bind(), // it shows the second child })
I'm trying to show child1 first, but child2(Box) forces itself to show up first. It worked when I replaced Box(child2) with EventBox.
ags version
: 1.8.0I notice this issue when I was writing this script. The child2 forces itself to show up first when it's a box widget, so I use EventBox instead. The code below is just a short sample.