Skip to content

Alt menus (mnemonics) do not work properly #336

@fvanheeswijk

Description

@fvanheeswijk

We are facing an issue in our application where our menu bar and items are not properly reachable when using alt + mnemonics from inside the webview.

Reproducible code is below:

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

using Microsoft.Web.WebView2.WinForms;

namespace WebView2BugMnemonics
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(CreateTestForm());
        }

        public static Form CreateTestForm()
        {
            var form = new Form
            {
                Size = new Size(1280, 1024)
            };

            var menuStrip = new MenuStrip
            {
                Dock = DockStyle.Top
            };
            var soundMenuItem = new ToolStripMenuItem("Sound", null, new ToolStripMenuItem("Switch on"));
            var settingsMenuItem = new ToolStripMenuItem("Settings", null, soundMenuItem);
            menuStrip.Items.Add(settingsMenuItem);


            var webView2 = new WebView2
            {
                Dock = DockStyle.Fill,
                Source = new Uri(@"about:blank")
            };
            webView2.CoreWebView2Ready += (sender, e) =>
            {
                webView2.CoreWebView2.Navigate("https://www.google.com");
            };


            var textBox = new TextBox
            {
                Dock = DockStyle.Bottom
            };

            form.Controls.Add(menuStrip);
            form.Controls.Add(webView2);
            form.Controls.Add(textBox);

            return form;
        }
    }
}

When you put the focus in the textbox and press Alt + S + S + S/Enter the 'Switch on' menu item will get executed, however when you perform exactly the same actions in the search bar on Google within the webview it does not work as expected. We expect it to work the same as compared to when executing it in the textbox.

AB#27801085

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestfeature requesttrackedWe are tracking this work internally.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions