Scroll container mouse pass through
This commit is contained in:
parent
71d50cab4b
commit
9c37cb8fef
@ -100,6 +100,31 @@ func (element *ScrollContainer) HandleKeyUp (key tomo.Key, modifiers tomo.Modifi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (element *ScrollContainer) HandleMouseDown (x, y int, button tomo.Button) {
|
||||||
|
if child, ok := element.child.(tomo.MouseTarget); ok {
|
||||||
|
child.HandleMouseDown(x, y, button)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (element *ScrollContainer) HandleMouseUp (x, y int, button tomo.Button) {
|
||||||
|
if child, ok := element.child.(tomo.MouseTarget); ok {
|
||||||
|
child.HandleMouseUp(x, y, button)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (element *ScrollContainer) HandleMouseMove (x, y int) {
|
||||||
|
if child, ok := element.child.(tomo.MouseTarget); ok {
|
||||||
|
child.HandleMouseMove(x, y)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (element *ScrollContainer) HandleMouseScroll (
|
||||||
|
x, y int,
|
||||||
|
deltaX, deltaY float64,
|
||||||
|
) {
|
||||||
|
// TODO: do not pass this down to the child
|
||||||
|
}
|
||||||
|
|
||||||
func (element *ScrollContainer) Selected () (selected bool) {
|
func (element *ScrollContainer) Selected () (selected bool) {
|
||||||
return element.selected
|
return element.selected
|
||||||
}
|
}
|
||||||
@ -213,6 +238,13 @@ func (element *ScrollContainer) draw () {
|
|||||||
artist.Paste(element.core, element.child, image.Point { })
|
artist.Paste(element.core, element.child, image.Point { })
|
||||||
element.drawHorizontalBar()
|
element.drawHorizontalBar()
|
||||||
element.drawVerticalBar()
|
element.drawVerticalBar()
|
||||||
|
artist.FillRectangle (
|
||||||
|
element, theme.BackgroundPattern(),
|
||||||
|
image.Rect (
|
||||||
|
element.vertical.bounds.Min.X,
|
||||||
|
element.horizontal.bounds.Min.Y,
|
||||||
|
element.vertical.bounds.Max.X,
|
||||||
|
element.horizontal.bounds.Max.Y))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (element *ScrollContainer) drawHorizontalBar () {
|
func (element *ScrollContainer) drawHorizontalBar () {
|
||||||
|
@ -58,7 +58,7 @@ func (element *TextBox) HandleMouseDown (x, y int, button tomo.Button) {
|
|||||||
|
|
||||||
func (element *TextBox) HandleMouseUp (x, y int, button tomo.Button) { }
|
func (element *TextBox) HandleMouseUp (x, y int, button tomo.Button) { }
|
||||||
func (element *TextBox) HandleMouseMove (x, y int) { }
|
func (element *TextBox) HandleMouseMove (x, y int) { }
|
||||||
func (element *TextBox) HandleScroll (x, y int, deltaX, deltaY float64) { }
|
func (element *TextBox) HandleMouseScroll (x, y int, deltaX, deltaY float64) { }
|
||||||
|
|
||||||
func (element *TextBox) HandleKeyDown (
|
func (element *TextBox) HandleKeyDown (
|
||||||
key tomo.Key,
|
key tomo.Key,
|
||||||
|
@ -20,7 +20,7 @@ func run () {
|
|||||||
textBox := basic.NewTextBox("", "sample text sample text")
|
textBox := basic.NewTextBox("", "sample text sample text")
|
||||||
scrollContainer := basic.NewScrollContainer(true, true)
|
scrollContainer := basic.NewScrollContainer(true, true)
|
||||||
scrollContainer.Adopt(textBox)
|
scrollContainer.Adopt(textBox)
|
||||||
container.Adopt(scrollContainer, false)
|
container.Adopt(scrollContainer, true)
|
||||||
|
|
||||||
window.OnClose(tomo.Stop)
|
window.OnClose(tomo.Stop)
|
||||||
window.Show()
|
window.Show()
|
||||||
|
Reference in New Issue
Block a user