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

Submenus not working on mobile #5398

Closed
2 tasks done
pneumaticdeath opened this issue Jan 11, 2025 · 4 comments
Closed
2 tasks done

Submenus not working on mobile #5398

pneumaticdeath opened this issue Jan 11, 2025 · 4 comments
Labels
blocker Items that would block a forthcoming release bug Something isn't working

Comments

@pneumaticdeath
Copy link

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

When I have menuItmes with child menus they can't be accessed when in a mobile layout

How to reproduce

  1. Run code below with --tags miobile
  2. Select menu Main
  3. Select menu Foo
  4. Unable to select Bar or Baz menu

Screenshots

Screenshot 2025-01-11 at 13 54 50

Example code

package main

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

func main() {
	a := app.New()
	w := a.NewWindow("Multi layered menus")

	entry := widget.NewEntry()

	barMI := fyne.NewMenuItem("Bar", func() { entry.Text = "Bar"; entry.Refresh() })
	bazMI := fyne.NewMenuItem("Baz", func() { entry.Text = "Baz"; entry.Refresh() })
	barbazMenu := fyne.NewMenu("Foo", barMI, bazMI)
	fooMI := fyne.NewMenuItem("Foo", func() {})
	fooMI.ChildMenu = barbazMenu
	fooMenu := fyne.NewMenu("Main", fooMI)
	mainMenu := fyne.NewMainMenu(fooMenu)

	w.SetMainMenu(mainMenu)
	w.SetContent(entry)

	w.ShowAndRun()
}

Fyne version

v2.5.3

Go compiler version

1.23.4

Operating system and version

macOS Sonoma 14.6.1

Additional Information

works fine in desktop mode

@pneumaticdeath pneumaticdeath added the unverified A bug that has been reported but not verified label Jan 11, 2025
@andydotxyz
Copy link
Member

Your fooMI has an action associated with it (the empty function) so it cannot open the submenu.

Replace that with nil and the code works.

	barMI := fyne.NewMenuItem("Bar", func() { entry.Text = "Bar"; entry.Refresh() })
	bazMI := fyne.NewMenuItem("Baz", func() { entry.Text = "Baz"; entry.Refresh() })
	barbazMenu := fyne.NewMenu("Foo", barMI, bazMI)
	fooMI := fyne.NewMenuItem("Foo", nil)
	fooMI.ChildMenu = barbazMenu
	fooMenu := fyne.NewMenu("Main", fooMI)
	mainMenu := fyne.NewMainMenu(fooMenu)

@pneumaticdeath
Copy link
Author

Then I'd classify this as a documentation bug, since the behavior is inconsistent with desktop.

@andydotxyz
Copy link
Member

Consistency is more important than better docs in this situation I think, opened a PR to resolve that - sorry for the confusion...

@andydotxyz
Copy link
Member

Fixed on develop. Beware that we are going through some threading changes there right now so I wouldn't switch immediately but in a couple of days it should be safer - we are making a smoother migration path so that health warnings are not required ;)

@andydotxyz andydotxyz added bug Something isn't working blocker Items that would block a forthcoming release and removed unverified A bug that has been reported but not verified labels Jan 15, 2025
@andydotxyz andydotxyz added this to the "F" release, Early 2025 milestone Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker Items that would block a forthcoming release bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants