Make Fyne popup menu appear at mouse position

Viewed 833

I'm stuck at getting the position of the mouse. I want to show the Fyne popup menu at the position of the mouse but can't figure it out.

Here's how I use the popup:

menuItem1 := fyne.NewMenuItem("A", nil)
menuItem2 := fyne.NewMenuItem("B", nil)
menuItem3 := fyne.NewMenuItem("C", nil)
menu := fyne.NewMenu("File", menuItem1, menuItem2, menuItem3)

popUpMenu := widget.NewPopUpMenu(menu, window.Canvas())

popUpMenu.ShowAtPosition(*Expect mouse position here*)
popUpMenu.Show()

I would expect to put in the mouse position as a Fyne Position at the mentioned position. But I don't know where I can get the mouse/cursor position from.

This way the popup is always stuck to the top left of the app.

1 Answers
Related