Added DisownAll method to Container
This commit is contained in:
		
							parent
							
								
									cb2136f7cb
								
							
						
					
					
						commit
						b3e6beb8ad
					
				@ -81,6 +81,19 @@ func (element *Container) Disown (child tomo.Element) {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// DisownAll removes all child elements from the container at once.
 | 
			
		||||
func (element *Container) DisownAll () {
 | 
			
		||||
	element.children = nil
 | 
			
		||||
 | 
			
		||||
	element.updateMinimumSize()
 | 
			
		||||
	element.updateSelectable()
 | 
			
		||||
	element.recalculate()
 | 
			
		||||
	if element.core.HasImage() {
 | 
			
		||||
		element.draw()
 | 
			
		||||
		element.core.PushAll()
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Children returns a slice containing this element's children.
 | 
			
		||||
func (element *Container) Children () (children []tomo.Element) {
 | 
			
		||||
	children = make([]tomo.Element, len(element.children))
 | 
			
		||||
 | 
			
		||||
@ -20,9 +20,7 @@ func run () {
 | 
			
		||||
	button   := basic.NewButton("drawing pad")
 | 
			
		||||
	okButton := basic.NewButton("OK")
 | 
			
		||||
	button.OnClick (func () {
 | 
			
		||||
		container.Disown(label)
 | 
			
		||||
		container.Disown(button)
 | 
			
		||||
		container.Disown(okButton)
 | 
			
		||||
		container.DisownAll()
 | 
			
		||||
		container.Adopt(basic.NewLabel("Draw here:"), false)
 | 
			
		||||
		container.Adopt(basic.NewTest(), true)
 | 
			
		||||
		container.Adopt(okButton, false)
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user