Browse Source

Merge branch 'master' into fixes/3180

pull/3186/head
danwalmsley 7 years ago
committed by GitHub
parent
commit
bea61f13fc
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      native/Avalonia.Native/src/OSX/window.mm
  2. 20
      src/Avalonia.Controls/ListBox.cs
  3. 4
      src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs
  4. 10
      src/Avalonia.Controls/Primitives/TabStrip.cs
  5. 2
      src/Avalonia.Controls/Primitives/Thumb.cs
  6. 8
      src/Avalonia.Controls/TextBox.cs
  7. 19
      src/Avalonia.Controls/TreeView.cs
  8. 2
      src/Avalonia.Input/AccessKeyHandler.cs
  9. 2
      src/Avalonia.Input/FocusManager.cs

11
native/Avalonia.Native/src/OSX/window.mm

@ -855,8 +855,15 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent
if(type == Wheel) if(type == Wheel)
{ {
delta.X = [event scrollingDeltaX] / 50; auto speed = 5;
delta.Y = [event scrollingDeltaY] / 50;
if([event hasPreciseScrollingDeltas])
{
speed = 50;
}
delta.X = [event scrollingDeltaX] / speed;
delta.Y = [event scrollingDeltaY] / speed;
if(delta.X == 0 && delta.Y == 0) if(delta.X == 0 && delta.Y == 0)
{ {

20
src/Avalonia.Controls/ListBox.cs

@ -7,6 +7,7 @@ using Avalonia.Controls.Presenters;
using Avalonia.Controls.Primitives; using Avalonia.Controls.Primitives;
using Avalonia.Controls.Templates; using Avalonia.Controls.Templates;
using Avalonia.Input; using Avalonia.Input;
using Avalonia.VisualTree;
namespace Avalonia.Controls namespace Avalonia.Controls
{ {
@ -132,14 +133,19 @@ namespace Avalonia.Controls
{ {
base.OnPointerPressed(e); base.OnPointerPressed(e);
if (e.MouseButton == MouseButton.Left || e.MouseButton == MouseButton.Right) if (e.Source is IVisual source)
{ {
e.Handled = UpdateSelectionFromEventSource( var point = e.GetCurrentPoint(source);
e.Source,
true, if (point.Properties.IsLeftButtonPressed || point.Properties.IsRightButtonPressed)
(e.InputModifiers & InputModifiers.Shift) != 0, {
(e.InputModifiers & InputModifiers.Control) != 0, e.Handled = UpdateSelectionFromEventSource(
e.MouseButton == MouseButton.Right); e.Source,
true,
(e.KeyModifiers & KeyModifiers.Shift) != 0,
(e.KeyModifiers & KeyModifiers.Control) != 0,
point.Properties.IsRightButtonPressed);
}
} }
} }

4
src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs

@ -804,9 +804,9 @@ namespace Avalonia.Controls
private void TextBoxOnPointerPressed(object sender, PointerPressedEventArgs e) private void TextBoxOnPointerPressed(object sender, PointerPressedEventArgs e)
{ {
if (e.Device.Captured != Spinner) if (e.Pointer.Captured != Spinner)
{ {
Dispatcher.UIThread.InvokeAsync(() => { e.Device.Capture(Spinner); }, DispatcherPriority.Input); Dispatcher.UIThread.InvokeAsync(() => { e.Pointer.Capture(Spinner); }, DispatcherPriority.Input);
} }
} }

10
src/Avalonia.Controls/Primitives/TabStrip.cs

@ -5,6 +5,7 @@ using Avalonia.Controls.Generators;
using Avalonia.Controls.Templates; using Avalonia.Controls.Templates;
using Avalonia.Input; using Avalonia.Input;
using Avalonia.Layout; using Avalonia.Layout;
using Avalonia.VisualTree;
namespace Avalonia.Controls.Primitives namespace Avalonia.Controls.Primitives
{ {
@ -44,9 +45,14 @@ namespace Avalonia.Controls.Primitives
{ {
base.OnPointerPressed(e); base.OnPointerPressed(e);
if (e.MouseButton == MouseButton.Left) if (e.Source is IVisual source)
{ {
e.Handled = UpdateSelectionFromEventSource(e.Source); var point = e.GetCurrentPoint(source);
if (point.Properties.IsLeftButtonPressed)
{
e.Handled = UpdateSelectionFromEventSource(e.Source);
}
} }
} }
} }

2
src/Avalonia.Controls/Primitives/Thumb.cs

@ -73,7 +73,6 @@ namespace Avalonia.Controls.Primitives
protected override void OnPointerPressed(PointerPressedEventArgs e) protected override void OnPointerPressed(PointerPressedEventArgs e)
{ {
e.Device.Capture(this);
e.Handled = true; e.Handled = true;
_lastPoint = e.GetPosition(this); _lastPoint = e.GetPosition(this);
@ -92,7 +91,6 @@ namespace Avalonia.Controls.Primitives
{ {
if (_lastPoint.HasValue) if (_lastPoint.HasValue)
{ {
e.Device.Capture(null);
e.Handled = true; e.Handled = true;
_lastPoint = null; _lastPoint = null;

8
src/Avalonia.Controls/TextBox.cs

@ -677,13 +677,13 @@ namespace Avalonia.Controls
} }
} }
e.Device.Capture(_presenter); e.Pointer.Capture(_presenter);
e.Handled = true; e.Handled = true;
} }
protected override void OnPointerMoved(PointerEventArgs e) protected override void OnPointerMoved(PointerEventArgs e)
{ {
if (_presenter != null && e.Device.Captured == _presenter) if (_presenter != null && e.Pointer.Captured == _presenter)
{ {
var point = e.GetPosition(_presenter); var point = e.GetPosition(_presenter);
@ -694,9 +694,9 @@ namespace Avalonia.Controls
protected override void OnPointerReleased(PointerReleasedEventArgs e) protected override void OnPointerReleased(PointerReleasedEventArgs e)
{ {
if (_presenter != null && e.Device.Captured == _presenter) if (_presenter != null && e.Pointer.Captured == _presenter)
{ {
e.Device.Capture(null); e.Pointer.Capture(null);
} }
} }

19
src/Avalonia.Controls/TreeView.cs

@ -507,14 +507,19 @@ namespace Avalonia.Controls
{ {
base.OnPointerPressed(e); base.OnPointerPressed(e);
if (e.MouseButton == MouseButton.Left || e.MouseButton == MouseButton.Right) if (e.Source is IVisual source)
{ {
e.Handled = UpdateSelectionFromEventSource( var point = e.GetCurrentPoint(source);
e.Source,
true, if (point.Properties.IsLeftButtonPressed || point.Properties.IsRightButtonPressed)
(e.InputModifiers & InputModifiers.Shift) != 0, {
(e.InputModifiers & InputModifiers.Control) != 0, e.Handled = UpdateSelectionFromEventSource(
e.MouseButton == MouseButton.Right); e.Source,
true,
(e.KeyModifiers & KeyModifiers.Shift) != 0,
(e.KeyModifiers & KeyModifiers.Control) != 0,
point.Properties.IsRightButtonPressed);
}
} }
} }

2
src/Avalonia.Input/AccessKeyHandler.cs

@ -182,7 +182,7 @@ namespace Avalonia.Input
{ {
bool menuIsOpen = MainMenu?.IsOpen == true; bool menuIsOpen = MainMenu?.IsOpen == true;
if ((e.Modifiers & InputModifiers.Alt) != 0 || menuIsOpen) if ((e.KeyModifiers & KeyModifiers.Alt) != 0 || menuIsOpen)
{ {
// If any other key is pressed with the Alt key held down, or the main menu is open, // If any other key is pressed with the Alt key held down, or the main menu is open,
// find all controls who have registered that access key. // find all controls who have registered that access key.

2
src/Avalonia.Input/FocusManager.cs

@ -180,7 +180,7 @@ namespace Avalonia.Input
if (sender == e.Source && ev.MouseButton == MouseButton.Left) if (sender == e.Source && ev.MouseButton == MouseButton.Left)
{ {
var element = (ev.Device?.Captured as IInputElement) ?? (e.Source as IInputElement); var element = (ev.Pointer?.Captured as IInputElement) ?? (e.Source as IInputElement);
if (element == null || !CanFocus(element)) if (element == null || !CanFocus(element))
{ {

Loading…
Cancel
Save