From 5409dc4ef266ba2edce3186923219b704a880b7c Mon Sep 17 00:00:00 2001 From: gucio321 <73652197+gucio321@users.noreply.github.com> Date: Sat, 19 Dec 2020 21:28:40 +0100 Subject: [PATCH] fixed onHover bug in d2ui.Label (#991) Co-authored-by: M. Sz --- d2core/d2ui/label.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/d2core/d2ui/label.go b/d2core/d2ui/label.go index 3dda47fd..4a09a322 100644 --- a/d2core/d2ui/label.go +++ b/d2core/d2ui/label.go @@ -46,6 +46,10 @@ func (ui *UIManager) NewLabel(fontPath, palettePath string) *Label { result.bindManager(ui) + result.SetVisible(false) + + ui.addWidget(result) + return result } @@ -96,11 +100,6 @@ func (v *Label) Render(target d2interface.Surface) { target.Pop() } -// GetSize returns the size of the label -func (v *Label) GetSize() (width, height int) { - return v.font.GetTextMetrics(v.text) -} - // GetTextMetrics returns the width and height of the enclosing rectangle in Pixels. func (v *Label) GetTextMetrics(text string) (width, height int) { return v.font.GetTextMetrics(text) @@ -109,6 +108,7 @@ func (v *Label) GetTextMetrics(text string) (width, height int) { // SetText sets the label's text func (v *Label) SetText(newText string) { v.text = v.processColorTokens(newText) + v.BaseWidget.width, v.BaseWidget.height = v.font.GetTextMetrics(v.text) } // GetText returns label text