Closed
Description
Checklist
- I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
- This issue only relates to a single bug. I will open new issues for any other problems.
Describe the bug
Create a widget with the Tappable interface. Add a child widget with the Hoverable interface. If the child widget is shown, the Tapped() function is never called. Hide the child widget and the Tapped() function is called as expected.
How to reproduce
- Run the example (it starts up with the child being shown
- Click on the child (solid black square)
- Note that there is no log entry indicating the Tapped() function being called on the parent widget. Click outside the child (solid black square) and you'll get the log entry.
- Remember the location of the child (solid black square). Click on the Hide Child button and the child will disappear. Now click where the child was. You'll get the Tapped() call.
Screenshots
Example code
package main
import (
"image/color"
"log"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/driver/desktop"
"fyne.io/fyne/v2/widget"
)
func main() {
testApp := app.New()
w := testApp.NewWindow("Test Tappable with Hoverable Child")
w.Resize(fyne.NewSize(600, 600))
pw := newParentWidget()
showButton := widget.NewButton("Show Child", func() {
pw.cw.Show()
})
hideButton := widget.NewButton("Hide Child", func() {
pw.cw.Hide()
})
showButton.Resize(showButton.MinSize())
hideButton.Resize(hideButton.MinSize())
topVbox := container.NewVBox(showButton, hideButton)
vBox := container.NewVBox(topVbox, pw)
w.SetContent(vBox)
w.ShowAndRun()
}
var _ fyne.Tappable = (*parentWidget)(nil)
type parentWidget struct {
widget.BaseWidget
cw *childWidget
}
func newParentWidget() *parentWidget {
pw := &parentWidget{}
pw.BaseWidget.ExtendBaseWidget(pw)
pw.cw = newChildWidget()
return pw
}
func (pw *parentWidget) CreateRenderer() fyne.WidgetRenderer {
pwr := &parentWidgetRenderer{
pw: pw,
parentRect: canvas.NewRectangle(color.Black),
}
pwr.parentRect.FillColor = color.Transparent
return pwr
}
func (pw *parentWidget) Tapped(*fyne.PointEvent) {
log.Print("Parent widget tapped")
}
type parentWidgetRenderer struct {
pw *parentWidget
parentRect *canvas.Rectangle
}
func (pwr *parentWidgetRenderer) Destroy() {
}
func (pwr *parentWidgetRenderer) Layout(size fyne.Size) {
pwr.parentRect.Resize(size)
pwr.pw.cw.Move(fyne.NewPos(25, 25))
pwr.pw.cw.Resize(fyne.NewSize(50, 50))
}
func (pwr *parentWidgetRenderer) MinSize() fyne.Size {
return fyne.NewSize(100, 100)
}
func (pwr *parentWidgetRenderer) Objects() []fyne.CanvasObject {
obj := []fyne.CanvasObject{
pwr.parentRect,
pwr.pw.cw,
}
return obj
}
func (pwr *parentWidgetRenderer) Refresh() {
}
var _ desktop.Hoverable = (*childWidget)(nil)
type childWidget struct {
widget.BaseWidget
}
func newChildWidget() *childWidget {
cw := &childWidget{}
cw.BaseWidget.ExtendBaseWidget(cw)
return cw
}
func (cw *childWidget) CreateRenderer() fyne.WidgetRenderer {
cwr := &childWidgetRenderer{
cw: cw,
childRectangle: canvas.NewRectangle(color.Black),
}
return cwr
}
func (cw *childWidget) MouseIn(*desktop.MouseEvent) {
}
func (cw *childWidget) MouseMoved(*desktop.MouseEvent) {
}
func (cw *childWidget) MouseOut() {
}
type childWidgetRenderer struct {
cw *childWidget
childRectangle *canvas.Rectangle
}
func (cwr *childWidgetRenderer) Destroy() {
}
func (cwr *childWidgetRenderer) Layout(size fyne.Size) {
cwr.childRectangle.Resize(size)
}
func (cwr *childWidgetRenderer) MinSize() fyne.Size {
return fyne.NewSize(50, 50)
}
func (cwr *childWidgetRenderer) Objects() []fyne.CanvasObject {
obj := []fyne.CanvasObject{
cwr.childRectangle,
}
return obj
}
func (cwr *childWidgetRenderer) Refresh() {
}
Fyne version
2.3.3
Go compiler version
1.20.3
Operating system and version
Windows 10 19045.2965
Additional Information
No response
Activity