Przeglądaj źródła

Fixed null reference in Keybindings Scenario and hotkey collision (#1965)

Thomas Nind 2 lat temu
rodzic
commit
08ea331134
1 zmienionych plików z 9 dodań i 2 usunięć
  1. 9 2
      UICatalog/KeyBindingsDialog.cs

+ 9 - 2
UICatalog/KeyBindingsDialog.cs

@@ -132,7 +132,7 @@ namespace UICatalog {
 				Width = Dim.Percent (50),
 				Height = Dim.Percent (100) - 1,
 			};
-			commandsListView.SelectedItemChanged += CommandsListView_SelectedItemChanged;
+
 			Add (commandsListView);
 
 			keyLabel = new Label () {
@@ -143,7 +143,7 @@ namespace UICatalog {
 			};
 			Add (keyLabel);
 
-			var btnChange = new Button ("Change") {
+			var btnChange = new Button ("Ch_ange") {
 				X = Pos.Percent (50),
 				Y = 1,
 			};
@@ -160,6 +160,13 @@ namespace UICatalog {
 			var cancel = new Button ("Cancel");
 			cancel.Clicked += ()=>Application.RequestStop();
 			AddButton (cancel);
+
+			// Register event handler as the last thing in constructor to prevent early calls
+			// before it is even shown (e.g. OnEnter)
+			commandsListView.SelectedItemChanged += CommandsListView_SelectedItemChanged;
+
+			// Setup to show first ListView entry
+			SetTextBoxToShowBinding (commands.First());
 		}
 
 		private void RemapKey ()