aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.SharedUI
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-09-17 14:49:49 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-09-17 14:49:49 +0300
commit11f81e3ce227dddd7ee3c73cc3f848293f04fef3 (patch)
treebe3eae402046ad76441ce9cb2d50be954d59264f /Software/Visual_Studio/Tango.SharedUI
parent410f6abd1cdec9d01130dac3a80358b7f8a37a14 (diff)
downloadTango-11f81e3ce227dddd7ee3c73cc3f848293f04fef3.tar.gz
Tango-11f81e3ce227dddd7ee3c73cc3f848293f04fef3.zip
Added support for mouse wheel on SearchComboBox.
Diffstat (limited to 'Software/Visual_Studio/Tango.SharedUI')
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Controls/SearchComboBox.cs85
1 files changed, 71 insertions, 14 deletions
diff --git a/Software/Visual_Studio/Tango.SharedUI/Controls/SearchComboBox.cs b/Software/Visual_Studio/Tango.SharedUI/Controls/SearchComboBox.cs
index d7439f702..f1543e05f 100644
--- a/Software/Visual_Studio/Tango.SharedUI/Controls/SearchComboBox.cs
+++ b/Software/Visual_Studio/Tango.SharedUI/Controls/SearchComboBox.cs
@@ -74,31 +74,42 @@ namespace Tango.SharedUI.Controls
IsOpened = false;
SelectedItem = _listBox.SelectedItem;
}
+ else if (e.Key == Key.Up && _listBox.SelectedIndex == 0)
+ {
+ _textBox.Focus();
+ Keyboard.Focus(_textBox);
+ }
}
private void _textBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Down)
{
- if (!String.IsNullOrWhiteSpace(SearchFilter))
- {
- _listBox.SelectedIndex = 0;
- }
+ e.Handled = true;
+ FocusList();
+ }
+ }
- Keyboard.Focus(_listBox);
+ private void FocusList()
+ {
+ if (!String.IsNullOrWhiteSpace(SearchFilter))
+ {
+ _listBox.SelectedIndex = 0;
+ }
- if (_listBox.SelectedIndex != -1)
+ Keyboard.Focus(_listBox);
+
+ if (_listBox.SelectedIndex != -1)
+ {
+ var container = _listBox.ItemContainerGenerator.ContainerFromIndex(_listBox.SelectedIndex) as UIElement;
+ if (container != null)
{
- var container = _listBox.ItemContainerGenerator.ContainerFromIndex(_listBox.SelectedIndex) as UIElement;
- if (container != null)
- {
- container.Focus();
- Keyboard.Focus(container);
- }
+ container.Focus();
+ Keyboard.Focus(container);
}
- e.Handled = true;
- _listBox.ScrollIntoView(_listBox.SelectedItem);
}
+
+ _listBox.ScrollIntoView(_listBox.SelectedItem);
}
private void _listBox_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
@@ -185,6 +196,52 @@ namespace Tango.SharedUI.Controls
e.Handled = false;
}
+ protected override void OnPreviewMouseWheel(MouseWheelEventArgs e)
+ {
+ e.Handled = true;
+
+ if (!_listBox.IsFocused)
+ {
+ FocusList();
+ }
+
+ if (e.Delta > 0)
+ {
+ _listBox.RaiseEvent(
+ new KeyEventArgs(
+ System.Windows.Input.Keyboard.PrimaryDevice,
+ PresentationSource.FromVisual(_listBox), 0, Key.Down)
+ { RoutedEvent = System.Windows.Input.Keyboard.KeyDownEvent });
+
+ _listBox.RaiseEvent(
+ new KeyEventArgs(
+ System.Windows.Input.Keyboard.PrimaryDevice,
+ PresentationSource.FromVisual(_listBox), 0, Key.Down)
+ { RoutedEvent = System.Windows.Input.Keyboard.KeyUpEvent });
+ }
+ else
+ {
+ _listBox.RaiseEvent(
+ new KeyEventArgs(
+ System.Windows.Input.Keyboard.PrimaryDevice,
+ PresentationSource.FromVisual(_listBox), 0, Key.Up)
+ { RoutedEvent = System.Windows.Input.Keyboard.KeyDownEvent });
+
+ _listBox.RaiseEvent(
+ new KeyEventArgs(
+ System.Windows.Input.Keyboard.PrimaryDevice,
+ PresentationSource.FromVisual(_listBox), 0, Key.Up)
+ { RoutedEvent = System.Windows.Input.Keyboard.KeyUpEvent });
+ }
+ //base.OnPreviewMouseWheel(e);
+ }
+
+ protected override void OnMouseWheel(MouseWheelEventArgs e)
+ {
+ e.Handled = true;
+ //base.OnMouseWheel(e);
+ }
+
static SearchComboBox()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(SearchComboBox), new FrameworkPropertyMetadata(typeof(SearchComboBox)));