Selectable elements can now request the selection to be moved
This commit is contained in:
@@ -103,6 +103,7 @@ func (element *Button) HandleSelection (
|
||||
) (
|
||||
accepted bool,
|
||||
) {
|
||||
direction = direction.Canon()
|
||||
if !element.enabled { return false }
|
||||
if element.selected && direction != tomo.SelectionDirectionNeutral {
|
||||
return false
|
||||
|
||||
@@ -43,6 +43,9 @@ func (element *Container) SetLayout (layout tomo.Layout) {
|
||||
// whatever way is defined by the current layout.
|
||||
func (element *Container) Adopt (child tomo.Element, expand bool) {
|
||||
child.SetParentHooks (tomo.ParentHooks {
|
||||
Draw: func (region tomo.Canvas) {
|
||||
element.drawChildRegion(child, region)
|
||||
},
|
||||
MinimumSizeChange: func (int, int) {
|
||||
element.updateMinimumSize()
|
||||
},
|
||||
@@ -51,8 +54,12 @@ func (element *Container) Adopt (child tomo.Element, expand bool) {
|
||||
if !selectable { return }
|
||||
return element.childSelectionRequestCallback(child)
|
||||
},
|
||||
Draw: func (region tomo.Canvas) {
|
||||
element.drawChildRegion(child, region)
|
||||
SelectionMotionRequest: func (
|
||||
direction tomo.SelectionDirection,
|
||||
) (
|
||||
granted bool,
|
||||
) {
|
||||
return element.core.RequestSelectionMotion(direction)
|
||||
},
|
||||
})
|
||||
element.children = append (element.children, tomo.LayoutEntry {
|
||||
|
||||
Reference in New Issue
Block a user