added requested add text feature
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/data/binding"
|
||||
"fyne.io/fyne/v2/driver/desktop"
|
||||
"fyne.io/fyne/v2/layout"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
)
|
||||
@@ -241,12 +242,15 @@ func estimateWallTangent(mid image.Point, wallMask *PixelMask) (float64, float64
|
||||
|
||||
type tappableImage struct {
|
||||
widget.BaseWidget
|
||||
image *fyne.Container
|
||||
onTapped func()
|
||||
image *fyne.Container
|
||||
onTapped func(*fyne.PointEvent)
|
||||
onSecondaryTap func(*fyne.PointEvent)
|
||||
onHover func(fyne.Position)
|
||||
onHoverEnd func()
|
||||
}
|
||||
|
||||
// newTappableImage wraps a container so taps can trigger image interactions.
|
||||
func newTappableImage(img *fyne.Container, tapped func()) *tappableImage {
|
||||
func newTappableImage(img *fyne.Container, tapped func(*fyne.PointEvent)) *tappableImage {
|
||||
ti := &tappableImage{
|
||||
image: img,
|
||||
onTapped: tapped,
|
||||
@@ -261,9 +265,33 @@ func (t *tappableImage) CreateRenderer() fyne.WidgetRenderer {
|
||||
}
|
||||
|
||||
// Tapped invokes the handler and is used for click interactions.
|
||||
func (t *tappableImage) Tapped(*fyne.PointEvent) {
|
||||
func (t *tappableImage) Tapped(ev *fyne.PointEvent) {
|
||||
if t.onTapped != nil {
|
||||
t.onTapped()
|
||||
t.onTapped(ev)
|
||||
}
|
||||
}
|
||||
|
||||
// TappedSecondary invokes the secondary handler and is used for right-click interactions.
|
||||
func (t *tappableImage) TappedSecondary(ev *fyne.PointEvent) {
|
||||
if t.onSecondaryTap != nil {
|
||||
t.onSecondaryTap(ev)
|
||||
}
|
||||
}
|
||||
|
||||
// MouseMoved forwards hover updates and is used for preview positioning.
|
||||
func (t *tappableImage) MouseMoved(ev *desktop.MouseEvent) {
|
||||
if t.onHover != nil {
|
||||
t.onHover(ev.Position)
|
||||
}
|
||||
}
|
||||
|
||||
// MouseIn is required by desktop.Hoverable.
|
||||
func (t *tappableImage) MouseIn(*desktop.MouseEvent) {}
|
||||
|
||||
// MouseOut clears hover state and is used when previews leave the canvas.
|
||||
func (t *tappableImage) MouseOut() {
|
||||
if t.onHoverEnd != nil {
|
||||
t.onHoverEnd()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user