From fb9d4c2115ee66010eec674bd75c563dce4e9a17 Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Fri, 23 Feb 2024 08:25:28 -0800 Subject: [PATCH] custom Hyperlink mod - add SizeName property --- widget/hyperlink.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/widget/hyperlink.go b/widget/hyperlink.go index db3cbc4f2f..43bce6bb61 100644 --- a/widget/hyperlink.go +++ b/widget/hyperlink.go @@ -27,6 +27,9 @@ type Hyperlink struct { // Since: 2.5 Truncation fyne.TextTruncation + // Custom for Supersonic - unreleased in Fyne + SizeName fyne.ThemeSizeName + // OnTapped overrides the default `fyne.OpenURL` call when the link is tapped // // Since: 2.2 @@ -243,16 +246,22 @@ func (hl *Hyperlink) openURL() { func (hl *Hyperlink) syncSegments() { hl.provider.Wrapping = hl.Wrapping hl.provider.Truncation = hl.Truncation + sizeName := theme.SizeNameText + if hl.SizeName != "" { + sizeName = hl.SizeName + } hl.provider.Segments = []RichTextSegment{&TextSegment{ Style: RichTextStyle{ Alignment: hl.Alignment, ColorName: theme.ColorNameHyperlink, Inline: true, TextStyle: hl.TextStyle, + SizeName: sizeName, }, Text: hl.Text, }} - hl.textSize = fyne.MeasureText(hl.Text, theme.TextSize(), hl.TextStyle) + th := fyne.CurrentApp().Settings().Theme() + hl.textSize = fyne.MeasureText(hl.Text, th.Size(sizeName), hl.TextStyle) } var _ fyne.WidgetRenderer = (*hyperlinkRenderer)(nil)