boxlayout: handle widget removal (#160)

This commit is contained in:
Adam Bozanich 2017-09-14 23:13:49 -07:00 committed by Garrett D'Amore
parent d55f61ca94
commit 582c2db721
1 changed files with 5 additions and 1 deletions

View File

@ -291,12 +291,16 @@ func (b *BoxLayout) InsertWidget(index int, widget Widget, fill float64) {
// RemoveWidget removes a Widget from the layout.
func (b *BoxLayout) RemoveWidget(widget Widget) {
changed := false
for i := 0; i < len(b.cells); i++ {
if b.cells[i].widget == widget {
b.cells = append(b.cells[:i], b.cells[i+1:]...)
return
changed = true
}
}
if !changed {
return
}
b.changed = true
widget.Unwatch(b)
b.layout()