forked from Leak_Technologies/VideoTools
Resolved naming conflict with existing tappableRenderer in components.go by renaming the renderer in TappableOverlay to overlayRenderer. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
65 lines
1.7 KiB
Go
65 lines
1.7 KiB
Go
package ui
|
|
|
|
import (
|
|
"fyne.io/fyne/v2"
|
|
"fyne.io/fyne/v2/widget"
|
|
)
|
|
|
|
// TappableOverlay is an invisible widget that captures tap and double-tap events
|
|
type TappableOverlay struct {
|
|
widget.BaseWidget
|
|
OnTapped func()
|
|
OnDoubleTapped func()
|
|
OnSecondaryTapped func()
|
|
}
|
|
|
|
// NewTappableOverlay creates a new tappable overlay
|
|
func NewTappableOverlay(onTapped, onDoubleTapped, onSecondaryTapped func()) *TappableOverlay {
|
|
t := &TappableOverlay{
|
|
OnTapped: onTapped,
|
|
OnDoubleTapped: onDoubleTapped,
|
|
OnSecondaryTapped: onSecondaryTapped,
|
|
}
|
|
t.ExtendBaseWidget(t)
|
|
return t
|
|
}
|
|
|
|
// Tapped handles single tap events
|
|
func (t *TappableOverlay) Tapped(*fyne.PointEvent) {
|
|
if t.OnTapped != nil {
|
|
t.OnTapped()
|
|
}
|
|
}
|
|
|
|
// TappedSecondary handles right-click events
|
|
func (t *TappableOverlay) TappedSecondary(*fyne.PointEvent) {
|
|
if t.OnSecondaryTapped != nil {
|
|
t.OnSecondaryTapped()
|
|
}
|
|
}
|
|
|
|
// DoubleTapped handles double-tap events
|
|
func (t *TappableOverlay) DoubleTapped(*fyne.PointEvent) {
|
|
if t.OnDoubleTapped != nil {
|
|
t.OnDoubleTapped()
|
|
}
|
|
}
|
|
|
|
// CreateRenderer implements fyne.Widget
|
|
func (t *TappableOverlay) CreateRenderer() fyne.WidgetRenderer {
|
|
return &overlayRenderer{}
|
|
}
|
|
|
|
// MinSize returns minimum size (should fill parent)
|
|
func (t *TappableOverlay) MinSize() fyne.Size {
|
|
return fyne.NewSize(1, 1)
|
|
}
|
|
|
|
type overlayRenderer struct{}
|
|
|
|
func (r *overlayRenderer) Layout(size fyne.Size) {}
|
|
func (r *overlayRenderer) MinSize() fyne.Size { return fyne.NewSize(1, 1) }
|
|
func (r *overlayRenderer) Refresh() {}
|
|
func (r *overlayRenderer) Objects() []fyne.CanvasObject { return nil }
|
|
func (r *overlayRenderer) Destroy() {}
|