Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ScrollEvent.Position and ScrollEvent.AbsolutePosition is 0,0 #2199

Closed
pwiecz opened this issue Apr 25, 2021 · 4 comments
Closed

ScrollEvent.Position and ScrollEvent.AbsolutePosition is 0,0 #2199

pwiecz opened this issue Apr 25, 2021 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@pwiecz
Copy link
Contributor

pwiecz commented Apr 25, 2021

I create Scrolled(*fyne.ScrollEvent) method on my widget. It gets called when I scroll the mouse wheel, but the Position and AbsolutePosition fields of the ScrollEvent seem to be all zeroes.
I was expecting to find mouse position there.

OS: Linux (Ubuntu 20.04)
Fyne version: v2.0.2

@pwiecz pwiecz added the bug Something isn't working label Apr 25, 2021
@Jacalz
Copy link
Member

Jacalz commented Apr 25, 2021

I see that you have chosen the bug template but discarded it. Can you please use the template (bug in this case) when opening issues? It is there to allow us to get enough, and the correct, information to be able to reproduce and help fix the issues.

@pwiecz
Copy link
Contributor Author

pwiecz commented Apr 26, 2021

Sorry about the.
If it helps I'll write the more complete report below.

Describe the bug:

I create Scrolled(*fyne.ScrollEvent) method on my widget. It gets called when I scroll the mouse wheel, but the Position and AbsolutePosition fields of the ScrollEvent seem to be all zeroes.

To Reproduce:

Steps to reproduce the behaviour:

  1. Create a custom widget that implements Scrollable interface.
  2. Inside the Scrolled function log the ScrollEvent.Position.
  3. Add the widget to an app.
  4. Run the app
  5. Move mouse over the widget, and scroll the wheel (or use touchpad scrolling)
  6. Look at the logs
  7. Expected: { mouseX, mouseY}, got {0, 0}

Screenshots:

Not - applicable

Example code:

package main

import (
	"fmt"

	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/widget"
)

type Widget struct {
	widget.BaseWidget
}

func (w *Widget) CreateRenderer() fyne.WidgetRenderer {
	return w
}
func (w *Widget) Scrolled(event *fyne.ScrollEvent) {
	fmt.Println(event.Position, event.AbsolutePosition)
}
func (w *Widget) Layout(size fyne.Size)        {}
func (w *Widget) MinSize() fyne.Size           { return fyne.Size{640, 480} }
func (w *Widget) Refresh()                     {}
func (w *Widget) Destroy()                     {}
func (w *Widget) Objects() []fyne.CanvasObject { return nil }
func main() {
	a := app.New()
	win := a.NewWindow("Test scroll")
	w := &Widget{}
	w.ExtendBaseWidget(w)
	win.SetContent(w)
	win.ShowAndRun()
}

Device (please complete the following information):

  • OS: Linux
  • Version: 5.4.0-72
  • Go version: 1.16.2
  • Fyne version: 2.0.2

@Jacalz
Copy link
Member

Jacalz commented Apr 26, 2021

Thank you. Very much appreciated 🙂

@andydotxyz
Copy link
Member

Fix in PR #2204, I hope we can land this for v2.0.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants