fixed onHover bug in d2ui.Label (#991)

Co-authored-by: M. Sz <mszeptuch@protonmail.com>
This commit is contained in:
gucio321 2020-12-19 21:28:40 +01:00 committed by GitHub
parent fbfea917cb
commit 5409dc4ef2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 5 deletions

View File

@ -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