Files
Terminal.Gui/UICatalog/Scenarios/Generic.cs
Tig 7ba6d638bc Fixes #3918 and #3913 - Accepting behavior (#3921)
* Fixed #3905, #3918

* Tweaked Generic

* Label code cleanup

* Clean up.

* Clean up.

* Clean up2.
2025-02-26 12:40:45 -07:00

40 lines
1.2 KiB
C#

#nullable enable
using Terminal.Gui;
namespace UICatalog.Scenarios;
[ScenarioMetadata ("Generic", "Generic sample - A template for creating new Scenarios")]
[ScenarioCategory ("Controls")]
public sealed class Generic : Scenario
{
public override void Main ()
{
// Init
Application.Init ();
// Setup - Create a top-level application window and configure it.
Window appWindow = new ()
{
Title = GetQuitKeyAndName (),
};
var button = new Button { Id = "button", X = Pos.Center (), Y = 1, Text = "_Press me!" };
button.Accepting += (s, e) =>
{
// Anytime Accepting is handled, make sure to set e.Cancel to false.
e.Cancel = true;
MessageBox.ErrorQuery ("Error", "You pressed the button!", "_Ok");
};
appWindow.Add (button);
// Run - Start the application.
Application.Run (appWindow);
appWindow.Dispose ();
// Shutdown - Calling Application.Shutdown is required.
Application.Shutdown ();
}
}