Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new method for Box to clear the children. #352

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions box.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import "C"
// There can also be space between each control ("padding").
type Box struct {
ControlBase
b *C.uiBox
children []Control
b *C.uiBox
children []Control
}

// NewHorizontalBox creates a new horizontal Box.
Expand Down Expand Up @@ -67,7 +67,7 @@ func (b *Box) Append(child Control, stretchy bool) {

// Delete deletes the nth control of the Box.
func (b *Box) Delete(n int) {
b.children = append(b.children[:n], b.children[n + 1:]...)
b.children = append(b.children[:n], b.children[n+1:]...)
C.uiBoxDelete(b.b, C.int(n))
}

Expand All @@ -83,3 +83,11 @@ func (b *Box) Padded() bool {
func (b *Box) SetPadded(padded bool) {
C.uiBoxSetPadded(b.b, frombool(padded))
}

// Clear clears the children of the Box.
func (b *Box) Clear() {
n := len(b.children)
for index := 0; index < n; index++ {
b.Delete(0)
}
}