diff --git a/box.go b/box.go index a6d6615..5c9ca88 100644 --- a/box.go +++ b/box.go @@ -294,6 +294,14 @@ func (this *box) boxUnder (point image.Point) anyBox { } } +func (this *box) handleFocusEnter () { + this.on.focusEnter.Broadcast() +} + +func (this *box) handleFocusLeave () { + this.on.focusLeave.Broadcast() +} + func (this *box) handleMouseDown (button input.Button) { for _, listener := range this.on.mouseDown.Listeners() { listener(button) diff --git a/system.go b/system.go index d3745fd..f071522 100644 --- a/system.go +++ b/system.go @@ -48,8 +48,19 @@ type anyBox interface { boxUnder (image.Point) anyBox recalculateMinimumSize () - handleMouseDown (input.Button) - handleMouseUp (input.Button) + handleFocusEnter () + handleFocusLeave () + // handleDndEnter () + // handleDndLeave () + // handleDndDrop (data.Data) + // handleMouseEnter () + // handleMouseLeave () + // handleMouseMove () + handleMouseDown (input.Button) + handleMouseUp (input.Button) + // handleScroll (float64, float64) + // handleKeyDown (input.Key, bool) + // handleKeyUp (input.Key, bool) } func assertAnyBox (unknown tomo.Box) anyBox { @@ -100,9 +111,18 @@ func (window *window) invalidateLayout (box anyBox) { func (window *window) focus (box anyBox) { if window.focused == box { return } - window.invalidateDraw(window.focused) + + previous := window.focused window.focused = box - window.invalidateDraw(box) + + if previous != nil { + window.invalidateDraw(previous) + previous.handleFocusLeave() + } + if box != nil { + window.invalidateDraw(box) + box.handleFocusEnter() + } } func (this *window) boxUnder (point image.Point) anyBox { diff --git a/textbox.go b/textbox.go index 4688f21..fb739ee 100644 --- a/textbox.go +++ b/textbox.go @@ -149,14 +149,6 @@ func (this *textBox) doLayout () { innerBounds := this.InnerBounds() this.drawer.SetMaxWidth(innerBounds.Dx()) this.drawer.SetMaxHeight(innerBounds.Dy()) - // if this.hOverflow && !this.wrap { - // this.drawer.SetMaxWidth(0) - // } else { - // } - // if this.vOverflow { - // this.drawer.SetMaxHeight(0) - // } else { - // } this.contentBounds = this.normalizedLayoutBoundsSpace().Sub(this.scroll)