Terminal.Gui icon indicating copy to clipboard operation
Terminal.Gui copied to clipboard

Keys Not Captured first by `PopoverMenu`; Input falls through to underlying view

Open YourRobotOverlord opened this issue 6 months ago • 3 comments

Describe the bug PopoverMenu does not receive any key that is handled in the underlying view.

Example When a PopoverMenu is open, pressing the Up or Down arrow keys first moves the cursor in the next focused view (the underlying view? 🤔), rather than navigating through the context menu items.

To Reproduce Steps to reproduce the behavior:

  1. Open the Notepad scenario in UICatalog
  2. Add several lines of text to the editor
  3. Right-click on tab title to show context menu
  4. Press up repeatedly, then down repeatedly

Image

Expected behavior Arrow key input should be captured by the context menu immediately, moving the selection within the menu. The underlying text view should not respond to keyboard input while the menu is visible.

Actual behavior Arrow key presses affect the underlying text view (e.g., moving the caret), and only afterward begin navigating the menu.

Perhaps this is by design, but I'm unsure how to work around it.

Another Example

Image

Desktop:

  • OS: Windows 10.0.26100
  • WindowsDriver

Additional Context This also has the effect of disabling keys for the PopoverMenu if they are handled by the underlying view. For example, if you add the following code to the TextView in Notepad.cs, you will be unable to move up or down in the context menu using up/down arrows:

protected override bool OnKeyDown(Key key)
{
    if (key == Key.CursorUp || key == Key.CursorDown)
    {
        return true; // handle key event
    }

    return base.OnKeyDown(key);
}

YourRobotOverlord avatar Jun 22 '25 00:06 YourRobotOverlord

I'm really sorry about this but menuv2 is barely working and this is just part of that.

My PR on select->accept is foundational work required to make menuv2 actually work well.

I hope you can be patient as I work through this.

tig avatar Jun 22 '25 01:06 tig

I'm really sorry about this but menuv2 is barely working and this is just part of that.

My PR on select->accept is foundational work required to make menuv2 actually work well.

Gotcha

I hope you can be patient as I work through this.

Of course! I'll come back to it when it's ready. Shall I close this issue?

YourRobotOverlord avatar Jun 22 '25 03:06 YourRobotOverlord

No, leave it open. That way I can be completely sure.

tig avatar Jun 22 '25 13:06 tig