KeyboardTests.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759
  1. using Xunit.Abstractions;
  2. namespace Terminal.Gui.ApplicationTests;
  3. /// <summary>
  4. /// Application tests for keyboard support.
  5. /// </summary>
  6. public class KeyboardTests
  7. {
  8. public KeyboardTests (ITestOutputHelper output)
  9. {
  10. _output = output;
  11. #if DEBUG_IDISPOSABLE
  12. Responder.Instances.Clear ();
  13. RunState.Instances.Clear ();
  14. #endif
  15. }
  16. private readonly ITestOutputHelper _output;
  17. private object _timeoutLock;
  18. [Fact (Skip = "No longer valid test.")]
  19. [AutoInitShutdown]
  20. public void EnsuresTopOnFront_CanFocus_False_By_Keyboard ()
  21. {
  22. Toplevel top = new ();
  23. var win = new Window
  24. {
  25. Title = "win",
  26. X = 0,
  27. Y = 0,
  28. Width = 20,
  29. Height = 10
  30. };
  31. var tf = new TextField { Width = 10 };
  32. win.Add (tf);
  33. var win2 = new Window
  34. {
  35. Title = "win2",
  36. X = 22,
  37. Y = 0,
  38. Width = 20,
  39. Height = 10
  40. };
  41. var tf2 = new TextField { Width = 10 };
  42. win2.Add (tf2);
  43. top.Add (win, win2);
  44. Application.Begin (top);
  45. Assert.True (win.CanFocus);
  46. Assert.True (win.HasFocus);
  47. Assert.True (win2.CanFocus);
  48. Assert.False (win2.HasFocus);
  49. Assert.Equal ("win", ((Window)top.Subviews [^1]).Title);
  50. win.CanFocus = false;
  51. Assert.False (win.CanFocus);
  52. Assert.False (win.HasFocus);
  53. Assert.True (win2.CanFocus);
  54. Assert.True (win2.HasFocus);
  55. Assert.Equal ("win2", ((Window)top.Subviews [^1]).Title);
  56. Application.OnKeyDown (Key.F6);
  57. Assert.True (win2.CanFocus);
  58. Assert.False (win.HasFocus);
  59. Assert.True (win2.CanFocus);
  60. Assert.True (win2.HasFocus);
  61. Assert.Equal ("win2", ((Window)top.Subviews [^1]).Title);
  62. Application.OnKeyDown (Key.F6);
  63. Assert.False (win.CanFocus);
  64. Assert.False (win.HasFocus);
  65. Assert.True (win2.CanFocus);
  66. Assert.True (win2.HasFocus);
  67. Assert.Equal ("win2", ((Window)top.Subviews [^1]).Title);
  68. top.Dispose ();
  69. }
  70. [Fact (Skip = "No longer valid test.")]
  71. [AutoInitShutdown]
  72. public void EnsuresTopOnFront_CanFocus_True_By_Keyboard ()
  73. {
  74. Toplevel top = new ();
  75. var win = new Window
  76. {
  77. Title = "win",
  78. X = 0,
  79. Y = 0,
  80. Width = 20,
  81. Height = 10
  82. };
  83. var tf = new TextField { Width = 10 };
  84. win.Add (tf);
  85. var win2 = new Window
  86. {
  87. Title = "win2",
  88. X = 22,
  89. Y = 0,
  90. Width = 20,
  91. Height = 10
  92. };
  93. var tf2 = new TextField { Width = 10 };
  94. win2.Add (tf2);
  95. top.Add (win, win2);
  96. Application.Begin (top);
  97. Assert.True (win.CanFocus);
  98. Assert.True (win.HasFocus);
  99. Assert.True (win2.CanFocus);
  100. Assert.False (win2.HasFocus);
  101. Assert.Equal ("win", ((Window)top.Subviews [^1]).Title);
  102. Application.OnKeyDown (Key.F6);
  103. Assert.True (win.CanFocus);
  104. Assert.False (win.HasFocus);
  105. Assert.True (win2.CanFocus);
  106. Assert.True (win2.HasFocus);
  107. Assert.Equal ("win2", ((Window)top.Subviews [^1]).Title);
  108. Application.OnKeyDown (Key.F6);
  109. Assert.True (win.CanFocus);
  110. Assert.True (win.HasFocus);
  111. Assert.True (win2.CanFocus);
  112. Assert.False (win2.HasFocus);
  113. Assert.Equal ("win", ((Window)top.Subviews [^1]).Title);
  114. top.Dispose ();
  115. }
  116. [Fact]
  117. [AutoInitShutdown]
  118. public void KeyBinding_Application_KeyBindings_Add_Adds ()
  119. {
  120. Application.KeyBindings.Add (Key.A, KeyBindingScope.Application, Command.Accept);
  121. Application.KeyBindings.Add (Key.B, KeyBindingScope.Application, Command.Accept);
  122. Assert.True (Application.KeyBindings.TryGet (Key.A, out KeyBinding binding));
  123. Assert.Null (binding.BoundView);
  124. Assert.True (Application.KeyBindings.TryGet (Key.B, out binding));
  125. Assert.Null (binding.BoundView);
  126. }
  127. [Fact]
  128. [AutoInitShutdown]
  129. public void KeyBinding_Application_RemoveKeyBinding_Removes ()
  130. {
  131. Application.KeyBindings.Add (Key.A, KeyBindingScope.Application, Command.Accept);
  132. Assert.True (Application.KeyBindings.TryGet (Key.A, out _));
  133. Application.KeyBindings.Remove (Key.A);
  134. Assert.False (Application.KeyBindings.TryGet (Key.A, out _));
  135. }
  136. [Fact]
  137. [AutoInitShutdown]
  138. public void KeyBinding_OnKeyDown ()
  139. {
  140. var view = new ScopedKeyBindingView ();
  141. var invoked = false;
  142. view.InvokingKeyBindings += (s, e) => invoked = true;
  143. var top = new Toplevel ();
  144. top.Add (view);
  145. Application.Begin (top);
  146. Application.OnKeyDown (Key.A);
  147. Assert.False (invoked);
  148. Assert.True (view.ApplicationCommand);
  149. invoked = false;
  150. view.ApplicationCommand = false;
  151. Application.KeyBindings.Remove (KeyCode.A);
  152. Application.OnKeyDown (Key.A); // old
  153. Assert.False (invoked);
  154. Assert.False (view.ApplicationCommand);
  155. Application.KeyBindings.Add (Key.A.WithCtrl, view, Command.Save);
  156. Application.OnKeyDown (Key.A); // old
  157. Assert.False (invoked);
  158. Assert.False (view.ApplicationCommand);
  159. Application.OnKeyDown (Key.A.WithCtrl); // new
  160. Assert.False (invoked);
  161. Assert.True (view.ApplicationCommand);
  162. invoked = false;
  163. Application.OnKeyDown (Key.H);
  164. Assert.True (invoked);
  165. invoked = false;
  166. Assert.False (view.HasFocus);
  167. Application.OnKeyDown (Key.F);
  168. Assert.False (invoked);
  169. Assert.True (view.ApplicationCommand);
  170. Assert.True (view.HotKeyCommand);
  171. Assert.False (view.FocusedCommand);
  172. top.Dispose ();
  173. }
  174. [Fact]
  175. [AutoInitShutdown]
  176. public void KeyBinding_OnKeyDown_Negative ()
  177. {
  178. var view = new ScopedKeyBindingView ();
  179. var invoked = false;
  180. view.InvokingKeyBindings += (s, e) => invoked = true;
  181. var top = new Toplevel ();
  182. top.Add (view);
  183. Application.Begin (top);
  184. Application.OnKeyDown (Key.A.WithCtrl);
  185. Assert.False (invoked);
  186. Assert.False (view.ApplicationCommand);
  187. Assert.False (view.HotKeyCommand);
  188. Assert.False (view.FocusedCommand);
  189. invoked = false;
  190. Assert.False (view.HasFocus);
  191. Application.OnKeyDown (Key.Z);
  192. Assert.False (invoked);
  193. Assert.False (view.ApplicationCommand);
  194. Assert.False (view.HotKeyCommand);
  195. Assert.False (view.FocusedCommand);
  196. top.Dispose ();
  197. }
  198. [Fact]
  199. [AutoInitShutdown]
  200. public void KeyBinding_View_KeyBindings_Add_Adds ()
  201. {
  202. View view1 = new ();
  203. Application.KeyBindings.Add (Key.A, view1, Command.Accept);
  204. View view2 = new ();
  205. Application.KeyBindings.Add (Key.B, view2, Command.Accept);
  206. Assert.True (Application.KeyBindings.TryGet (Key.A, out KeyBinding binding));
  207. Assert.Equal (view1, binding.BoundView);
  208. Assert.True (Application.KeyBindings.TryGet (Key.B, out binding));
  209. Assert.Equal (view2, binding.BoundView);
  210. }
  211. [Fact]
  212. [AutoInitShutdown]
  213. public void KeyBinding_View_KeyBindings_RemoveKeyBinding_Removes ()
  214. {
  215. View view1 = new ();
  216. Application.KeyBindings.Add (Key.A, view1, Command.Accept);
  217. View view2 = new ();
  218. Application.KeyBindings.Add (Key.B, view1, Command.Accept);
  219. Application.KeyBindings.Remove (Key.A, view1);
  220. Assert.False (Application.KeyBindings.TryGet (Key.A, out _));
  221. }
  222. [Fact]
  223. public void KeyUp_Event ()
  224. {
  225. Application.Init (new FakeDriver ());
  226. // Setup some fake keypresses (This)
  227. var input = "Tests";
  228. Key originalQuitKey = Application.QuitKey;
  229. Application.QuitKey = Key.Q.WithCtrl;
  230. // Put a control-q in at the end
  231. FakeConsole.MockKeyPresses.Push (new ('Q', ConsoleKey.Q, false, false, true));
  232. foreach (char c in input.Reverse ())
  233. {
  234. if (char.IsLetter (c))
  235. {
  236. FakeConsole.MockKeyPresses.Push (
  237. new (
  238. c,
  239. (ConsoleKey)char.ToUpper (c),
  240. char.IsUpper (c),
  241. false,
  242. false
  243. )
  244. );
  245. }
  246. else
  247. {
  248. FakeConsole.MockKeyPresses.Push (
  249. new (
  250. c,
  251. (ConsoleKey)c,
  252. false,
  253. false,
  254. false
  255. )
  256. );
  257. }
  258. }
  259. int stackSize = FakeConsole.MockKeyPresses.Count;
  260. var iterations = 0;
  261. Application.Iteration += (s, a) =>
  262. {
  263. iterations++;
  264. // Stop if we run out of control...
  265. if (iterations > 10)
  266. {
  267. Application.RequestStop ();
  268. }
  269. };
  270. var keyUps = 0;
  271. var output = string.Empty;
  272. var top = new Toplevel ();
  273. top.KeyUp += (sender, args) =>
  274. {
  275. if (args.KeyCode != (KeyCode.CtrlMask | KeyCode.Q))
  276. {
  277. output += args.AsRune;
  278. }
  279. keyUps++;
  280. };
  281. Application.Run (top);
  282. Application.QuitKey = originalQuitKey;
  283. // Input string should match output
  284. Assert.Equal (input, output);
  285. // # of key up events should match stack size
  286. //Assert.Equal (stackSize, keyUps);
  287. // We can't use numbers variables on the left side of an Assert.Equal/NotEqual,
  288. // it must be literal (Linux only).
  289. Assert.Equal (6, keyUps);
  290. // # of key up events should match # of iterations
  291. Assert.Equal (stackSize, iterations);
  292. top.Dispose ();
  293. Application.Shutdown ();
  294. Assert.Null (Application.Current);
  295. Assert.Null (Application.Top);
  296. Assert.Null (Application.MainLoop);
  297. Assert.Null (Application.Driver);
  298. }
  299. [Fact]
  300. public void NextTabGroupKey_Moves_Focus_To_TabStop_In_Next_TabGroup ()
  301. {
  302. // Arrange
  303. Application.Navigation = new ();
  304. var top = new Toplevel ();
  305. var view1 = new View
  306. {
  307. Id = "view1",
  308. CanFocus = true,
  309. TabStop = TabBehavior.TabGroup
  310. };
  311. var subView1 = new View
  312. {
  313. Id = "subView1",
  314. CanFocus = true,
  315. TabStop = TabBehavior.TabStop
  316. };
  317. view1.Add (subView1);
  318. var view2 = new View
  319. {
  320. Id = "view2",
  321. CanFocus = true,
  322. TabStop = TabBehavior.TabGroup
  323. };
  324. var subView2 = new View
  325. {
  326. Id = "subView2",
  327. CanFocus = true,
  328. TabStop = TabBehavior.TabStop
  329. };
  330. view2.Add (subView2);
  331. top.Add (view1, view2);
  332. Application.Top = top;
  333. Application.Current = top;
  334. view1.SetFocus ();
  335. Assert.True (view1.HasFocus);
  336. Assert.True (subView1.HasFocus);
  337. // Act
  338. Application.OnKeyDown (Application.NextTabGroupKey);
  339. // Assert
  340. Assert.True (view2.HasFocus);
  341. Assert.True (subView2.HasFocus);
  342. top.Dispose ();
  343. Application.Navigation = null;
  344. }
  345. [Fact]
  346. public void NextTabGroupKey_PrevTabGroupKey_Tests ()
  347. {
  348. Application.Init (new FakeDriver ());
  349. Toplevel top = new (); // TabGroup
  350. var w1 = new Window (); // TabGroup
  351. var v1 = new TextField (); // TabStop
  352. var v2 = new TextView (); // TabStop
  353. w1.Add (v1, v2);
  354. var w2 = new Window (); // TabGroup
  355. var v3 = new CheckBox (); // TabStop
  356. var v4 = new Button (); // TabStop
  357. w2.Add (v3, v4);
  358. top.Add (w1, w2);
  359. Application.Iteration += (s, a) =>
  360. {
  361. Assert.True (v1.HasFocus);
  362. // Across TabGroups
  363. Application.OnKeyDown (Key.F6);
  364. Assert.True (v3.HasFocus);
  365. Application.OnKeyDown (Key.F6);
  366. Assert.True (v1.HasFocus);
  367. Application.OnKeyDown (Key.F6.WithShift);
  368. Assert.True (v3.HasFocus);
  369. Application.OnKeyDown (Key.F6.WithShift);
  370. Assert.True (v1.HasFocus);
  371. // Restore?
  372. Application.OnKeyDown (Key.Tab);
  373. Assert.True (v2.HasFocus);
  374. Application.OnKeyDown (Key.F6);
  375. Assert.True (v3.HasFocus);
  376. Application.OnKeyDown (Key.F6);
  377. Assert.True (v2.HasFocus);
  378. Application.RequestStop ();
  379. };
  380. Application.Run (top);
  381. // Replacing the defaults keys to avoid errors on others unit tests that are using it.
  382. Application.NextTabGroupKey = Key.PageDown.WithCtrl;
  383. Application.PrevTabGroupKey = Key.PageUp.WithCtrl;
  384. Application.QuitKey = Key.Q.WithCtrl;
  385. Assert.Equal (KeyCode.PageDown | KeyCode.CtrlMask, Application.NextTabGroupKey.KeyCode);
  386. Assert.Equal (KeyCode.PageUp | KeyCode.CtrlMask, Application.PrevTabGroupKey.KeyCode);
  387. Assert.Equal (KeyCode.Q | KeyCode.CtrlMask, Application.QuitKey.KeyCode);
  388. top.Dispose ();
  389. // Shutdown must be called to safely clean up Application if Init has been called
  390. Application.Shutdown ();
  391. }
  392. [Fact]
  393. public void NextTabKey_Moves_Focus_To_Next_TabStop ()
  394. {
  395. // Arrange
  396. Application.Navigation = new ();
  397. var top = new Toplevel ();
  398. var view1 = new View { Id = "view1", CanFocus = true };
  399. var view2 = new View { Id = "view2", CanFocus = true };
  400. top.Add (view1, view2);
  401. Application.Top = top;
  402. Application.Current = top;
  403. view1.SetFocus ();
  404. // Act
  405. Application.OnKeyDown (Application.NextTabKey);
  406. // Assert
  407. Assert.True (view2.HasFocus);
  408. top.Dispose ();
  409. Application.Navigation = null;
  410. }
  411. [Fact]
  412. public void PrevTabGroupKey_Moves_Focus_To_TabStop_In_Prev_TabGroup ()
  413. {
  414. // Arrange
  415. Application.Navigation = new ();
  416. var top = new Toplevel ();
  417. var view1 = new View
  418. {
  419. Id = "view1",
  420. CanFocus = true,
  421. TabStop = TabBehavior.TabGroup
  422. };
  423. var subView1 = new View
  424. {
  425. Id = "subView1",
  426. CanFocus = true,
  427. TabStop = TabBehavior.TabStop
  428. };
  429. view1.Add (subView1);
  430. var view2 = new View
  431. {
  432. Id = "view2",
  433. CanFocus = true,
  434. TabStop = TabBehavior.TabGroup
  435. };
  436. var subView2 = new View
  437. {
  438. Id = "subView2",
  439. CanFocus = true,
  440. TabStop = TabBehavior.TabStop
  441. };
  442. view2.Add (subView2);
  443. top.Add (view1, view2);
  444. Application.Top = top;
  445. Application.Current = top;
  446. view1.SetFocus ();
  447. Assert.True (view1.HasFocus);
  448. Assert.True (subView1.HasFocus);
  449. // Act
  450. Application.OnKeyDown (Application.PrevTabGroupKey);
  451. // Assert
  452. Assert.True (view2.HasFocus);
  453. Assert.True (subView2.HasFocus);
  454. top.Dispose ();
  455. Application.Navigation = null;
  456. }
  457. [Fact]
  458. public void PrevTabKey_Moves_Focus_To_Prev_TabStop ()
  459. {
  460. // Arrange
  461. Application.Navigation = new ();
  462. var top = new Toplevel ();
  463. var view1 = new View { Id = "view1", CanFocus = true };
  464. var view2 = new View { Id = "view2", CanFocus = true };
  465. top.Add (view1, view2);
  466. Application.Top = top;
  467. Application.Current = top;
  468. view1.SetFocus ();
  469. // Act
  470. Application.OnKeyDown (Application.NextTabKey);
  471. // Assert
  472. Assert.True (view2.HasFocus);
  473. top.Dispose ();
  474. Application.Navigation = null;
  475. }
  476. [Fact]
  477. public void QuitKey_Default_Is_Esc ()
  478. {
  479. Application.ResetState (true);
  480. // Before Init
  481. Assert.Equal (Key.Esc, Application.QuitKey);
  482. Application.Init (new FakeDriver ());
  483. // After Init
  484. Assert.Equal (Key.Esc, Application.QuitKey);
  485. Application.Shutdown ();
  486. }
  487. [Fact]
  488. [AutoInitShutdown]
  489. public void QuitKey_Getter_Setter ()
  490. {
  491. Toplevel top = new ();
  492. var isQuiting = false;
  493. top.Closing += (s, e) =>
  494. {
  495. isQuiting = true;
  496. e.Cancel = true;
  497. };
  498. Application.Begin (top);
  499. top.Running = true;
  500. Key prevKey = Application.QuitKey;
  501. Application.OnKeyDown (Application.QuitKey);
  502. Assert.True (isQuiting);
  503. isQuiting = false;
  504. Application.OnKeyDown (Application.QuitKey);
  505. Assert.True (isQuiting);
  506. isQuiting = false;
  507. Application.QuitKey = Key.C.WithCtrl;
  508. Application.OnKeyDown (prevKey); // Should not quit
  509. Assert.False (isQuiting);
  510. Application.OnKeyDown (Key.Q.WithCtrl); // Should not quit
  511. Assert.False (isQuiting);
  512. Application.OnKeyDown (Application.QuitKey);
  513. Assert.True (isQuiting);
  514. // Reset the QuitKey to avoid throws errors on another tests
  515. Application.QuitKey = prevKey;
  516. top.Dispose ();
  517. }
  518. [Fact]
  519. public void QuitKey_Quits ()
  520. {
  521. Assert.Null (_timeoutLock);
  522. _timeoutLock = new ();
  523. uint abortTime = 500;
  524. var initialized = false;
  525. var iteration = 0;
  526. var shutdown = false;
  527. object timeout = null;
  528. Application.InitializedChanged += OnApplicationOnInitializedChanged;
  529. Application.Init (new FakeDriver ());
  530. Assert.True (initialized);
  531. Assert.False (shutdown);
  532. _output.WriteLine ("Application.Run<Toplevel> ().Dispose ()..");
  533. Application.Run<Toplevel> ().Dispose ();
  534. _output.WriteLine ("Back from Application.Run<Toplevel> ().Dispose ()");
  535. Assert.True (initialized);
  536. Assert.False (shutdown);
  537. Assert.Equal (1, iteration);
  538. Application.Shutdown ();
  539. Application.InitializedChanged -= OnApplicationOnInitializedChanged;
  540. lock (_timeoutLock)
  541. {
  542. if (timeout is { })
  543. {
  544. Application.RemoveTimeout (timeout);
  545. timeout = null;
  546. }
  547. }
  548. Assert.True (initialized);
  549. Assert.True (shutdown);
  550. #if DEBUG_IDISPOSABLE
  551. Assert.Empty (Responder.Instances);
  552. #endif
  553. lock (_timeoutLock)
  554. {
  555. _timeoutLock = null;
  556. }
  557. return;
  558. void OnApplicationOnInitializedChanged (object s, EventArgs<bool> a)
  559. {
  560. _output.WriteLine ("OnApplicationOnInitializedChanged: {0}", a.CurrentValue);
  561. if (a.CurrentValue)
  562. {
  563. Application.Iteration += OnApplicationOnIteration;
  564. initialized = true;
  565. lock (_timeoutLock)
  566. {
  567. timeout = Application.AddTimeout (TimeSpan.FromMilliseconds (abortTime), ForceCloseCallback);
  568. }
  569. }
  570. else
  571. {
  572. Application.Iteration -= OnApplicationOnIteration;
  573. shutdown = true;
  574. }
  575. }
  576. bool ForceCloseCallback ()
  577. {
  578. lock (_timeoutLock)
  579. {
  580. _output.WriteLine ($"ForceCloseCallback. iteration: {iteration}");
  581. if (timeout is { })
  582. {
  583. timeout = null;
  584. }
  585. }
  586. Application.ResetState (true);
  587. Assert.Fail ($"Failed to Quit with {Application.QuitKey} after {abortTime}ms. Force quit.");
  588. return false;
  589. }
  590. void OnApplicationOnIteration (object s, IterationEventArgs a)
  591. {
  592. _output.WriteLine ("Iteration: {0}", iteration);
  593. iteration++;
  594. Assert.True (iteration < 2, "Too many iterations, something is wrong.");
  595. if (Application.IsInitialized)
  596. {
  597. _output.WriteLine (" Pressing QuitKey");
  598. Application.OnKeyDown (Application.QuitKey);
  599. }
  600. }
  601. }
  602. // Test View for testing Application key Bindings
  603. public class ScopedKeyBindingView : View
  604. {
  605. public ScopedKeyBindingView ()
  606. {
  607. AddCommand (Command.Save, () => ApplicationCommand = true);
  608. AddCommand (Command.HotKey, () => HotKeyCommand = true);
  609. AddCommand (Command.Left, () => FocusedCommand = true);
  610. Application.KeyBindings.Add (Key.A, this, Command.Save);
  611. HotKey = KeyCode.H;
  612. KeyBindings.Add (Key.F, Command.Left);
  613. }
  614. public bool ApplicationCommand { get; set; }
  615. public bool FocusedCommand { get; set; }
  616. public bool HotKeyCommand { get; set; }
  617. }
  618. }