fix hyperlink truncating at fixed width
This commit is contained in:
@@ -12,14 +12,13 @@ type hyperlinkWrapper struct {
|
|||||||
|
|
||||||
h *widget.Hyperlink
|
h *widget.Hyperlink
|
||||||
l *widget.Label
|
l *widget.Label
|
||||||
maxWidth float32
|
MaxWidth float32
|
||||||
}
|
}
|
||||||
|
|
||||||
func newHyperlinkWrapper(maxWidth float32) *hyperlinkWrapper {
|
func newHyperlinkWrapper() *hyperlinkWrapper {
|
||||||
h := &hyperlinkWrapper{
|
h := &hyperlinkWrapper{
|
||||||
h: widget.NewHyperlink("", nil),
|
h: widget.NewHyperlink("", nil),
|
||||||
l: widget.NewLabel(""),
|
l: widget.NewLabel(""),
|
||||||
maxWidth: maxWidth,
|
|
||||||
}
|
}
|
||||||
h.h.Wrapping = fyne.TextTruncate
|
h.h.Wrapping = fyne.TextTruncate
|
||||||
h.ExtendBaseWidget(h)
|
h.ExtendBaseWidget(h)
|
||||||
@@ -27,7 +26,7 @@ func newHyperlinkWrapper(maxWidth float32) *hyperlinkWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *hyperlinkWrapper) MinSize() fyne.Size {
|
func (h *hyperlinkWrapper) MinSize() fyne.Size {
|
||||||
w := fyne.Min(h.maxWidth, h.l.MinSize().Width)
|
w := fyne.Min(h.MaxWidth, h.l.MinSize().Width)
|
||||||
return fyne.NewSize(w, h.h.MinSize().Height)
|
return fyne.NewSize(w, h.h.MinSize().Height)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +51,7 @@ type CustomHyperlink struct {
|
|||||||
|
|
||||||
func NewCustomHyperlink() *CustomHyperlink {
|
func NewCustomHyperlink() *CustomHyperlink {
|
||||||
c := &CustomHyperlink{
|
c := &CustomHyperlink{
|
||||||
h: newHyperlinkWrapper(200),
|
h: newHyperlinkWrapper(),
|
||||||
}
|
}
|
||||||
c.h.h.OnTapped = func() {
|
c.h.h.OnTapped = func() {
|
||||||
if c.OnTapped != nil {
|
if c.OnTapped != nil {
|
||||||
@@ -71,6 +70,11 @@ func (c *CustomHyperlink) SetText(text string) {
|
|||||||
c.Refresh()
|
c.Refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *CustomHyperlink) Resize(size fyne.Size) {
|
||||||
|
c.h.MaxWidth = size.Width
|
||||||
|
c.BaseWidget.Resize(size)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *CustomHyperlink) Refresh() {
|
func (c *CustomHyperlink) Refresh() {
|
||||||
c.container.Refresh()
|
c.container.Refresh()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user