From 08ea33113458d42794f10fd8534090e65e79bc79 Mon Sep 17 00:00:00 2001 From: Thomas Nind <31306100+tznind@users.noreply.github.com> Date: Thu, 25 Aug 2022 13:46:28 +0100 Subject: [PATCH] Fixed null reference in Keybindings Scenario and hotkey collision (#1965) --- UICatalog/KeyBindingsDialog.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/UICatalog/KeyBindingsDialog.cs b/UICatalog/KeyBindingsDialog.cs index cb2c1b9cf..95b1fcf91 100644 --- a/UICatalog/KeyBindingsDialog.cs +++ b/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 ()