Skip to content

Commit

Permalink
Fix nil canvas bug for ToolTipWidget custom widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
dweymouth committed Aug 3, 2024
1 parent dd647e2 commit 12f4f05
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions widget/tooltipwidget.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package widget

import (
"context"
"errors"
"sync"
"time"

Expand All @@ -26,22 +27,38 @@ type ToolTipWidget struct {
widget.BaseWidget
toolTipContext

wid fyne.Widget
toolTip string
}

func (t *ToolTipWidget) ExtendBaseWidget(wid fyne.Widget) {
t.wid = wid
t.BaseWidget.ExtendBaseWidget(wid)
}

func (t *ToolTipWidget) SetToolTip(toolTip string) {
t.lock.Lock()
defer t.lock.Unlock()
t.toolTip = toolTip
}

func (t *ToolTipWidget) ToolTip() string {
t.lock.Lock()
defer t.lock.Unlock()
return t.toolTip
}

func (t *ToolTipWidget) MouseIn(e *desktop.MouseEvent) {
t.lock.Lock()
defer t.lock.Unlock()
t.absoluteMousePos = e.AbsolutePosition
t.setPendingToolTip(t, t.toolTip)
if t.toolTip != "" {
t.absoluteMousePos = e.AbsolutePosition
if t.wid == nil {
fyne.LogError("", errors.New("missing ExtendBaseWidget call for ToolTipWidget"))
return
}
t.setPendingToolTip(t.wid, t.toolTip)
}
}

func (t *ToolTipWidget) MouseOut() {
Expand Down

0 comments on commit 12f4f05

Please sign in to comment.