From cc1c407756e2f909e7fc6b323cf665ad2c36215a Mon Sep 17 00:00:00 2001 From: MaxED Date: Tue, 23 Sep 2014 08:54:53 +0000 Subject: [PATCH] Action Selector control: actions can now be scrolled using up/down keys and mouse wheel. --- Source/Core/Controls/ActionSelectorControl.cs | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/Source/Core/Controls/ActionSelectorControl.cs b/Source/Core/Controls/ActionSelectorControl.cs index b56232ee..8e2ae8b6 100644 --- a/Source/Core/Controls/ActionSelectorControl.cs +++ b/Source/Core/Controls/ActionSelectorControl.cs @@ -50,6 +50,7 @@ namespace CodeImp.DoomBuilder.Controls { // Initialize InitializeComponent(); + number.MouseWheel += number_OnMouseWheel; //mxd } // This returns the numeric value @@ -223,6 +224,30 @@ namespace CodeImp.DoomBuilder.Controls // Allow CTRL+X, CTRL+C and CTRL+V if(controlpressed && ((e.KeyCode == Keys.X) || (e.KeyCode == Keys.C) || (e.KeyCode == Keys.V))) return; + //mxd. Scroll action list using arrow keys + if (e.KeyCode == Keys.Down) + { + if (list.SelectedIndex > 0) + { + list.SelectedIndex--; + list_SelectionChangeCommitted(list, EventArgs.Empty); + } + // Cancel this + e.Handled = true; + return; + } + if(e.KeyCode == Keys.Up) + { + if (list.SelectedIndex < list.Items.Count) + { + list.SelectedIndex++; + list_SelectionChangeCommitted(list, EventArgs.Empty); + } + // Cancel this + e.Handled = true; + return; + } + // Not numeric or control key? if(((e.KeyValue < 48) || (e.KeyValue > 57)) && (e.KeyCode != Keys.Back) && (e.KeyCode != Keys.Left) && @@ -246,6 +271,21 @@ namespace CodeImp.DoomBuilder.Controls e.Handled = true; } } + + //mxd. Scrolls action list using mouse wheel + private void number_OnMouseWheel(object sender, MouseEventArgs e) + { + if (e.Delta < 0 && list.SelectedIndex > 0) + { + list.SelectedIndex--; + list_SelectionChangeCommitted(list, EventArgs.Empty); + } + else if (e.Delta > 0 && list.SelectedIndex < list.Items.Count) + { + list.SelectedIndex++; + list_SelectionChangeCommitted(list, EventArgs.Empty); + } + } // Selection made private void list_SelectionChangeCommitted(object sender, EventArgs e)