PanelContainer: bug fix on destroying a panel
This commit fixes a bug where destroying a Panel with a parent of kind PanelKindSplit... causes the selected to become that split panel, instead of a child. Now, it chooses the leftmost child of that parent panel.
This commit is contained in:
parent
5df772e568
commit
14ba338de9
@ -76,15 +76,24 @@ func (c *PanelContainer) DeleteSelected() Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (*p).Left != nil {
|
if (*p).Left != nil {
|
||||||
|
// Parent becomes the Left panel
|
||||||
panel := (*p).Left.(*Panel)
|
panel := (*p).Left.(*Panel)
|
||||||
(*p).Left = (*panel).Left
|
(*p).Left = (*panel).Left
|
||||||
(*p).Right = (*panel).Right
|
(*p).Right = (*panel).Right
|
||||||
(*p).Kind = (*panel).Kind
|
(*p).Kind = (*panel).Kind
|
||||||
|
(*p).SplitAt = (*panel).SplitAt
|
||||||
} else {
|
} else {
|
||||||
(*p).Kind = PanelKindEmpty
|
(*p).Kind = PanelKindEmpty
|
||||||
}
|
}
|
||||||
|
|
||||||
c.changeSelected(&p)
|
// Decide what Panel to select next
|
||||||
|
if !(*p).IsLeaf() { // If the new panel was a split panel...
|
||||||
|
// Select the leftmost child of it
|
||||||
|
(*p).EachLeaf(false, func(l *Panel) bool { c.changeSelected(&l); return true })
|
||||||
|
} else {
|
||||||
|
c.changeSelected(&p)
|
||||||
|
}
|
||||||
|
|
||||||
(*p).UpdateSplits()
|
(*p).UpdateSplits()
|
||||||
} else if c.floatingMode { // Deleting a floating Panel without a parent
|
} else if c.floatingMode { // Deleting a floating Panel without a parent
|
||||||
c.floating[0] = nil
|
c.floating[0] = nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user