-
Notifications
You must be signed in to change notification settings - Fork 729
Closed
Milestone
Description
Describe the bug
When a View has 2 Button (A and B). Both have Accepting handler. One of which IsDefault then the default one is always fired even when clicking on the other button.
To Reproduce
Application.Init ();
Window w = new Window () { Width = Dim.Fill (), Height = Dim.Fill () };
var btn1 = new Button ()
{
Text = "A",
IsDefault = true,
};
btn1.Accepting += (s, e) => {
Debug.WriteLine ("A pressed");
Application.RequestStop ();
};
var btn2 = new Button ()
{
X = Pos.Right (btn1),
Text = "B"
};
btn2.Accepting += (s, e) =>
{
Debug.WriteLine ("B pressed");
Application.RequestStop ();
};
w.Add (btn1);
w.Add (btn2);
Application.Run (w);
w.Dispose ();
Application.Shutdown ();
return 0;When you click A you see
"Pressed A"
When you click B you see
"Pressed B"
"Pressed A"
Expected behavior
Button should not click itself!
** Workaround **
As a workaround you can have all the buttons that are not IsDefault call e.Cancel on the accepting event.
btn2.Accepting += (s, e) =>
{
Debug.WriteLine ("B pressed");
+ e.Cancel = true;
Application.RequestStop ();
};Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
✅ Done
