HotKeys.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. namespace UICatalog.Scenarios;
  2. [ScenarioMetadata ("HotKeys", "Demonstrates how HotKeys work.")]
  3. [ScenarioCategory ("Controls")]
  4. [ScenarioCategory ("Mouse and Keyboard")]
  5. public class HotKeys : Scenario
  6. {
  7. public override void Main ()
  8. {
  9. Application.Init ();
  10. Window app = new ()
  11. {
  12. Title = GetQuitKeyAndName ()
  13. };
  14. var textViewLabel = new Label { Text = "_TextView:", X = 0, Y = 0 };
  15. app.Add (textViewLabel);
  16. var textField = new TextField { X = Pos.Right (textViewLabel) + 1, Y = 0, Width = 10 };
  17. app.Add (textField);
  18. var viewLabel = new Label { Text = "_View:", X = 0, Y = Pos.Bottom (textField) + 1 };
  19. app.Add (viewLabel);
  20. var view = new View
  21. {
  22. Title = "View (_focusable)",
  23. Text = "Text renders _Underscore",
  24. CanFocus = true,
  25. X = Pos.Right (viewLabel) + 1, Y = Pos.Top (viewLabel), Width = 30, Height = 3,
  26. BorderStyle = LineStyle.Dashed
  27. };
  28. app.Add (view);
  29. viewLabel = new () { Text = "Vi_ew:", X = 0, Y = Pos.Bottom (view) + 1 };
  30. app.Add (viewLabel);
  31. view = new ()
  32. {
  33. Title = "View (n_ot focusable)",
  34. Text = "Text renders _Underscore",
  35. X = Pos.Right (viewLabel) + 1, Y = Pos.Top (viewLabel), Width = 30, Height = 3,
  36. BorderStyle = LineStyle.Dashed
  37. };
  38. app.Add (view);
  39. var labelWithFrameLabel = new Label { Text = "_Label with Frame:", X = 0, Y = Pos.Bottom (view) + 1 };
  40. app.Add (labelWithFrameLabel);
  41. var labelWithFrameFocusable = new Label
  42. {
  43. Title = "Label _with Frame (focusable)",
  44. CanFocus = true,
  45. X = Pos.Right (labelWithFrameLabel) + 1, Y = Pos.Top (labelWithFrameLabel), Width = 40, Height = 3,
  46. BorderStyle = LineStyle.Dashed
  47. };
  48. app.Add (labelWithFrameFocusable);
  49. labelWithFrameLabel = new () { Text = "L_abel with Frame:", X = 0, Y = Pos.Bottom (labelWithFrameFocusable) + 1 };
  50. app.Add (labelWithFrameLabel);
  51. var labelWithFrame = new Label
  52. {
  53. Title = "Label with Frame (_not focusable)",
  54. X = Pos.Right (labelWithFrameLabel) + 1, Y = Pos.Top (labelWithFrameLabel), Width = 40, Height = 3,
  55. BorderStyle = LineStyle.Dashed
  56. };
  57. app.Add (labelWithFrame);
  58. var buttonWithFrameLabel = new Label { Text = "_Button with Frame:", X = 0, Y = Pos.Bottom (labelWithFrame) + 1 };
  59. app.Add (buttonWithFrameLabel);
  60. var buttonWithFrameFocusable = new Button
  61. {
  62. Title = "B_utton with Frame (focusable)",
  63. CanFocus = true,
  64. X = Pos.Right (buttonWithFrameLabel) + 1, Y = Pos.Top (buttonWithFrameLabel), Width = 40,
  65. BorderStyle = LineStyle.Dashed
  66. };
  67. app.Add (buttonWithFrameFocusable);
  68. buttonWithFrameLabel = new () { Text = "Butt_on with Frame:", X = 0, Y = Pos.Bottom (buttonWithFrameFocusable) + 1 };
  69. app.Add (buttonWithFrameLabel);
  70. var buttonWithFrame = new Button
  71. {
  72. Title = "Button with Frame (not focusab_le)",
  73. X = Pos.Right (buttonWithFrameLabel) + 1, Y = Pos.Top (buttonWithFrameLabel), Width = 40,
  74. CanFocus = false,
  75. BorderStyle = LineStyle.Dashed
  76. };
  77. app.Add (buttonWithFrame);
  78. var checkboxWithFrameLabel = new Label { Text = "_Checkbox with Frame:", X = 0, Y = Pos.Bottom (buttonWithFrame) + 1 };
  79. app.Add (checkboxWithFrameLabel);
  80. var checkboxWithFrameFocusable = new CheckBox
  81. {
  82. Title = "C_heckbox with Frame (focusable)",
  83. CanFocus = true,
  84. X = Pos.Right (checkboxWithFrameLabel) + 1, Y = Pos.Top (checkboxWithFrameLabel), Width = 40, Height = 3,
  85. BorderStyle = LineStyle.Dashed
  86. };
  87. app.Add (checkboxWithFrameFocusable);
  88. checkboxWithFrameLabel = new () { Text = "Checkb_ox with Frame:", X = 0, Y = Pos.Bottom (checkboxWithFrameFocusable) + 1 };
  89. app.Add (checkboxWithFrameLabel);
  90. var checkboxWithFrame = new CheckBox
  91. {
  92. Title = "Checkbox with Frame (not focusable)",
  93. X = Pos.Right (checkboxWithFrameLabel) + 1, Y = Pos.Top (checkboxWithFrameLabel), Width = 40, Height = 3,
  94. CanFocus = false,
  95. BorderStyle = LineStyle.Dashed
  96. };
  97. app.Add (checkboxWithFrame);
  98. var button = new Button { X = Pos.Center (), Y = Pos.AnchorEnd (), Text = "_Press me!" };
  99. app.Add (button);
  100. Application.Run (app);
  101. app.Dispose ();
  102. Application.Shutdown ();
  103. }
  104. }