diff --git a/elements/basic/scrollcontainer.go b/elements/basic/scrollcontainer.go index 57ae279..4151fd7 100644 --- a/elements/basic/scrollcontainer.go +++ b/elements/basic/scrollcontainer.go @@ -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) { return element.selected } @@ -213,6 +238,13 @@ func (element *ScrollContainer) draw () { artist.Paste(element.core, element.child, image.Point { }) element.drawHorizontalBar() 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 () { diff --git a/elements/basic/textbox.go b/elements/basic/textbox.go index 537b742..59e9a07 100644 --- a/elements/basic/textbox.go +++ b/elements/basic/textbox.go @@ -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) 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 ( key tomo.Key, diff --git a/examples/scroll/main.go b/examples/scroll/main.go index e3cb55c..ca8b6bd 100644 --- a/examples/scroll/main.go +++ b/examples/scroll/main.go @@ -20,7 +20,7 @@ func run () { textBox := basic.NewTextBox("", "sample text sample text") scrollContainer := basic.NewScrollContainer(true, true) scrollContainer.Adopt(textBox) - container.Adopt(scrollContainer, false) + container.Adopt(scrollContainer, true) window.OnClose(tomo.Stop) window.Show()