DocumentContainer properly adopts children now
This commit is contained in:
parent
1239f4e03d
commit
5ca9206f65
@ -49,6 +49,8 @@ func (element *DocumentContainer) Adopt (child elements.Element) {
|
|||||||
Element: child,
|
Element: child,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
child.SetParent(element)
|
||||||
|
|
||||||
// refresh stale data
|
// refresh stale data
|
||||||
element.reflectChildProperties()
|
element.reflectChildProperties()
|
||||||
if element.core.HasImage() && !element.warping {
|
if element.core.HasImage() && !element.warping {
|
||||||
|
@ -148,7 +148,7 @@ func (element *List) HandleMouseUp (x, y int, button input.Button) {
|
|||||||
element.pressed = false
|
element.pressed = false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (element *List) HandleMouseMove (x, y int) {
|
func (element *List) HandleMotion (x, y int) {
|
||||||
if element.pressed {
|
if element.pressed {
|
||||||
if element.selectUnderMouse(x, y) && element.core.HasImage() {
|
if element.selectUnderMouse(x, y) && element.core.HasImage() {
|
||||||
element.draw()
|
element.draw()
|
||||||
@ -157,8 +157,6 @@ func (element *List) HandleMouseMove (x, y int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (element *List) HandleMouseScroll (x, y int, deltaX, deltaY float64) { }
|
|
||||||
|
|
||||||
func (element *List) HandleKeyDown (key input.Key, modifiers input.Modifiers) {
|
func (element *List) HandleKeyDown (key input.Key, modifiers input.Modifiers) {
|
||||||
if !element.Enabled() { return }
|
if !element.Enabled() { return }
|
||||||
|
|
||||||
|
@ -115,13 +115,13 @@ func (element *ScrollBar) HandleMouseUp (x, y int, button input.Button) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (element *ScrollBar) HandleMouseMove (x, y int) {
|
func (element *ScrollBar) HandleMotion (x, y int) {
|
||||||
if element.dragging {
|
if element.dragging {
|
||||||
element.dragTo(image.Pt(x, y))
|
element.dragTo(image.Pt(x, y))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (element *ScrollBar) HandleMouseScroll (x, y int, deltaX, deltaY float64) {
|
func (element *ScrollBar) HandleScroll (x, y int, deltaX, deltaY float64) {
|
||||||
if element.vertical {
|
if element.vertical {
|
||||||
element.scrollBy(int(deltaY))
|
element.scrollBy(int(deltaY))
|
||||||
} else {
|
} else {
|
||||||
|
@ -147,7 +147,7 @@ func (element *ScrollContainer) SetConfig (new config.Config) {
|
|||||||
element.redoAll()
|
element.redoAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (element *ScrollContainer) HandleMouseScroll (
|
func (element *ScrollContainer) HandleScroll (
|
||||||
x, y int,
|
x, y int,
|
||||||
deltaX, deltaY float64,
|
deltaX, deltaY float64,
|
||||||
) {
|
) {
|
||||||
|
@ -68,7 +68,7 @@ func (element *Slider) HandleMouseUp (x, y int, button input.Button) {
|
|||||||
element.redo()
|
element.redo()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (element *Slider) HandleMouseMove (x, y int) {
|
func (element *Slider) HandleMotion (x, y int) {
|
||||||
if element.dragging {
|
if element.dragging {
|
||||||
element.dragging = true
|
element.dragging = true
|
||||||
element.value = element.valueFor(x, y)
|
element.value = element.valueFor(x, y)
|
||||||
@ -79,7 +79,7 @@ func (element *Slider) HandleMouseMove (x, y int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (element *Slider) HandleMouseScroll (x, y int, deltaX, deltaY float64) { }
|
func (element *Slider) HandleScroll (x, y int, deltaX, deltaY float64) { }
|
||||||
|
|
||||||
func (element *Slider) HandleKeyDown (key input.Key, modifiers input.Modifiers) {
|
func (element *Slider) HandleKeyDown (key input.Key, modifiers input.Modifiers) {
|
||||||
switch key {
|
switch key {
|
||||||
|
@ -67,9 +67,6 @@ func (element *Switch) HandleMouseUp (x, y int, button input.Button) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (element *Switch) HandleMouseMove (x, y int) { }
|
|
||||||
func (element *Switch) HandleMouseScroll (x, y int, deltaX, deltaY float64) { }
|
|
||||||
|
|
||||||
func (element *Switch) HandleKeyDown (key input.Key, modifiers input.Modifiers) {
|
func (element *Switch) HandleKeyDown (key input.Key, modifiers input.Modifiers) {
|
||||||
if key == input.KeyEnter {
|
if key == input.KeyEnter {
|
||||||
element.pressed = true
|
element.pressed = true
|
||||||
|
@ -80,7 +80,7 @@ func (element *TextBox) HandleMouseDown (x, y int, button input.Button) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (element *TextBox) HandleMouseMove (x, y int) {
|
func (element *TextBox) HandleMotion (x, y int) {
|
||||||
if !element.Enabled() { return }
|
if !element.Enabled() { return }
|
||||||
|
|
||||||
if element.dragging {
|
if element.dragging {
|
||||||
@ -115,8 +115,6 @@ func (element *TextBox) HandleMouseUp (x, y int, button input.Button) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (element *TextBox) HandleMouseScroll (x, y int, deltaX, deltaY float64) { }
|
|
||||||
|
|
||||||
func (element *TextBox) HandleKeyDown(key input.Key, modifiers input.Modifiers) {
|
func (element *TextBox) HandleKeyDown(key input.Key, modifiers input.Modifiers) {
|
||||||
if element.onKeyDown != nil && element.onKeyDown(key, modifiers) {
|
if element.onKeyDown != nil && element.onKeyDown(key, modifiers) {
|
||||||
return
|
return
|
||||||
|
@ -212,10 +212,10 @@ func (propagator *Propagator) HandleMouseUp (x, y int, button input.Button) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// HandleMouseMove propagates the mouse event to the element that was last
|
// HandleMotion propagates the mouse event to the element that was last
|
||||||
// pressed down by the mouse if the mouse is currently being held down, else it
|
// pressed down by the mouse if the mouse is currently being held down, else it
|
||||||
// propagates the event to whichever element is underneath the mouse pointer.
|
// propagates the event to whichever element is underneath the mouse pointer.
|
||||||
func (propagator *Propagator) HandleMouseMove (x, y int) {
|
func (propagator *Propagator) HandleMotion (x, y int) {
|
||||||
handled := false
|
handled := false
|
||||||
for _, child := range propagator.drags {
|
for _, child := range propagator.drags {
|
||||||
if child, ok := child.(elements.MotionTarget); ok {
|
if child, ok := child.(elements.MotionTarget); ok {
|
||||||
@ -234,7 +234,7 @@ func (propagator *Propagator) HandleMouseMove (x, y int) {
|
|||||||
|
|
||||||
// HandleScroll propagates the mouse event to the element under the mouse
|
// HandleScroll propagates the mouse event to the element under the mouse
|
||||||
// pointer.
|
// pointer.
|
||||||
func (propagator *Propagator) HandleMouseScroll (x, y int, deltaX, deltaY float64) {
|
func (propagator *Propagator) HandleScroll (x, y int, deltaX, deltaY float64) {
|
||||||
child := propagator.childAt(image.Pt(x, y))
|
child := propagator.childAt(image.Pt(x, y))
|
||||||
if child, ok := child.(elements.ScrollTarget); ok {
|
if child, ok := child.(elements.ScrollTarget); ok {
|
||||||
child.HandleScroll(x, y, deltaX, deltaY)
|
child.HandleScroll(x, y, deltaX, deltaY)
|
||||||
|
@ -42,7 +42,7 @@ func (core *FocusableCore) Focused () (focused bool) {
|
|||||||
func (core *FocusableCore) Focus () {
|
func (core *FocusableCore) Focus () {
|
||||||
if !core.enabled || core.focused { return }
|
if !core.enabled || core.focused { return }
|
||||||
parent := core.core.Parent()
|
parent := core.core.Parent()
|
||||||
if parent, ok := parent.(elements.FocusableParent); ok && parent != nil {
|
if parent, ok := parent.(elements.FocusableParent); ok {
|
||||||
core.focused = parent.RequestFocus (
|
core.focused = parent.RequestFocus (
|
||||||
core.core.Outer().(elements.Focusable))
|
core.core.Outer().(elements.Focusable))
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user