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

TabView steals keypresses from active ContextMenu #3974

Open
tznind opened this issue Mar 9, 2025 · 1 comment · May be fixed by #3995
Open

TabView steals keypresses from active ContextMenu #3974

tznind opened this issue Mar 9, 2025 · 1 comment · May be fixed by #3995
Labels
Milestone

Comments

@tznind
Copy link
Collaborator

tznind commented Mar 9, 2025

Describe the bug
When a view has a TabView and you open a right click context menu in root view then the left/right keypresses are taken first by the tab view.

To Reproduce

  • Right click to open context menu
  • Navigate up and down and into and out of context menu submenu

Expected not to see tab view steal keystrokes.
You often have to press Left twice e.g. to collapse submenu


        Application.Init ();

        var win = new Window ()
        {
            Title = "My Window",
            X = 0,
            Y = 0,
            Width = Dim.Fill (),
            Height = Dim.Fill ()
        };

        // Tab View
        var tabView = new TabView ()
        {
            X = 1,
            Y = 1,
            Width = Dim.Fill () - 2,
            Height = Dim.Fill () - 2
        };
        tabView.AddTab (new Tab (){DisplayText = "Tab 1" }, true);
        tabView.AddTab (new Tab (){DisplayText = "Tab 2"}, false);
        win.Add (tabView);

        // Context Menu
        var contextMenu = new ContextMenu ();

        var menu =
            new MenuBarItem (
                             new MenuItem []
                             {
                                 new MenuItem ("Item 1", "First item", () => MessageBox.Query ("Action", "Item 1 Clicked", "OK")),
                                 new MenuBarItem (
                                                  "Submenu",
                                                  new List<MenuItem []>
                                                  {
                                                      new MenuItem []
                                                      {
                                                          new MenuItem (
                                                                        "Sub Item 1",
                                                                        "Submenu item",
                                                                        () =>
                                                                        {
                                                                            MessageBox.Query ("Action", "Sub Item 1 Clicked", "OK");
                                                                        })

                                                      }
                                                  })
                             });

        win.MouseClick += (s,e) =>
                          {
                              if (e.Flags.HasFlag (MouseFlags.Button3Clicked)) // Right-click
                              {
                                  contextMenu.Position = e.Position;
                                  contextMenu.Show (menu);
                              }
                          };

        Application.Run (win);
        Application.Shutdown ();

Expected behavior
While context menu is open the tab view should not be getting key presses.

Screenshots

Image

@tig
Copy link
Collaborator

tig commented Mar 9, 2025

@tznind when you create these can you please set the properties?

  • Type
  • Project
  • Milestone

@tznind tznind added this to the V2 Alpha milestone Mar 9, 2025
BDisp added a commit to BDisp/Terminal.Gui that referenced this issue Mar 18, 2025
@BDisp BDisp linked a pull request Mar 18, 2025 that will close this issue
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

2 participants