-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtappablecustomlabel.go
36 lines (25 loc) · 1.38 KB
/
tappablecustomlabel.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
/* TappableCustomLabel is a type extending the CustomLabel to be tappable */
/* ================================================================================ Imports */
import (
"fyne.io/fyne/v2"
)
/* ================================================================================ Public types */
type TappableCustomLabel struct {
CustomLabel
OnTapped func()
}
/* ================================================================================ Public functions */
func NewTappableCustomLabel(alignment fyne.TextAlign, style PaintStyle, lineWrapping bool, text string, textSize float32, textStyle fyne.TextStyle, paddingMultipliers, textPaddingOffsets Paddings, tapped func()) *TappableCustomLabel {
backgroundPaddings, textPaddings := CalculatePaddings(paddingMultipliers, textPaddingOffsets)
customLabel := CustomLabel{ Alignment: alignment, Style: style, LineWrapping: lineWrapping, Text: text, TextSize: textSize, TextStyle: textStyle, BackgroundPaddings: backgroundPaddings, TextPaddings: textPaddings }
tappableCustomLabel := &TappableCustomLabel{ customLabel, tapped }
tappableCustomLabel.ExtendBaseWidget(tappableCustomLabel)
return tappableCustomLabel
}
/* ================================================================================ Public methods */
func (w *TappableCustomLabel) Tapped(event *fyne.PointEvent) {
if w.OnTapped != nil {
w.OnTapped()
}
}