Skip to content

Resizing when a context menu is open causes the Enter event to get spammed #2095

@tznind

Description

@tznind

Describe the bug
The Enter event seems to be incorrectly firing while context menus are open. Here is an app that demos the problem (see below). It is most apparent when resizing. Although I have also seen Enter events fired at other times when a context menu is opened (I first noticed it in TerminalGuiDesigner), in that case I think Enter was firing when the submenu popped.

Expected behavior
While a context menu is open no Enter events should be raised unless they are directly registered on the context menu itself.

using Terminal.Gui;

Application.Init();
Application.Top.ColorScheme = Colors.Base;

// for logging output
var events = new TextView { ReadOnly = true, X = 50, Y = 1, Width = Dim.Fill(), Height = Dim.Fill(), Text = "Events:"};

// a root view
var root = new View() { Width = Dim.Fill(), Height = Dim.Fill(), ColorScheme = Colors.Base };
root.Enter += (s) => { events.Text += $"\nEntered root";};
root.Add(events);

// with a label (that is focusable)
var lbl = new Label("Name:") { Y = 0, CanFocus = true };
lbl.Enter += (s) => events.Text += $"\nEntered Label";
root.Add(lbl);

// and a text field
var tf = new TextField() { X = Pos.Right(lbl) + 1, Width = 10 };
tf.Enter += (s)=> events.Text += $"\nEntered TextField";
root.Add(tf);

Application.Top.Add(root);
Application.Run();

wierdevents
Resizing when context menu is open causes misfiring Enter events

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions