Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bug] Menu missing acceleratorsΒ #5211

@davidortinau

Description

@davidortinau

Description

I can create a menu and use the accelerator api, however it doesn't do anything. I should be able to use this or similar to add keyboard shortcuts to menu items.

void InitMenu()
		{
			var fileMenu = new MenuBarItem { Text = "File" };
			var exitItem = new MenuFlyoutItem
			{
				Text = "Exit",
				Command = new Command((obj) =>
				{
					Application.Current.Quit();
				})
			};
			MenuItem.SetAccelerator(exitItem, Accelerator.FromString("cmd+q"));
			fileMenu.Add(exitItem);

			var locationMenu = new MenuBarItem { Text = "Location" };
			var changeItem = new MenuFlyoutItem
			{
				Text = "Change",
				Command = new Command((obj) =>
				{
					Navigation.PushAsync(new ButtonPage());
				})
			};
			locationMenu.Add(changeItem);

			var refreshItem = new MenuFlyoutItem
			{
				Text = "Refresh"
			};
			MenuItem.SetAccelerator(refreshItem, Accelerator.FromString("cmd+r"));
			locationMenu.Add(refreshItem);

			this.MenuBarItems.Add(fileMenu);
			this.MenuBarItems.Add(locationMenu);
		}

Steps to Reproduce

Add the code above to a ContentPage, run it. Note no compiler error, and no keyboard support.

Version with bug

Release Candidate 1

Last version that worked well

Unknown/Other

Affected platforms

Windows, macOS

Affected platform versions

win11

Did you find any workaround?

No response

Relevant log output

No response

Metadata

Metadata

Labels

fixed-in-8.0.0-preview.7.8842Look for this fix in 8.0.0-preview.7.8842!legacy-area-desktopWindows / WinUI / Project Reunion & Mac Catalyst / macOS specifics (Menus & other Controls))p/1Work that is important, and has been scheduled for release in this or an upcoming sprintpartner/cat 😻this is an issue that impacts one of our partners or a customer our advisory team is engaged withplatform/macosmacOS / Mac Catalystplatform/windowss/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't workingt/desktopThe issue relates to desktop scenarios (MacOS/MacCatalyst/Windows/WinUI/WinAppSDK)

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions