Browse Source

[OSX] Add Swipe, Rotate and Magnify PitchToZoom trackpad gestures as native mouse events, because they can be triggered from magic mouse AFAIK and creation of new TrackpadDevice is too big task for me now

pull/6564/head
Sergey Mikolaitis 5 years ago
parent
commit
02e30f80f5
  1. 31
      native/Avalonia.Native/src/OSX/window.mm
  2. 5
      src/Avalonia.Native/avn.idl

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

@ -1625,6 +1625,19 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent
return;
}
}
else if (type == Magnify)
{
delta.X = delta.Y = [event magnification];
}
else if (type == Rotate)
{
delta.X = delta.Y = [event rotation];
}
else if (type == Swipe)
{
delta.X = [event deltaX];
delta.Y = [event deltaY];
}
auto timestamp = [event timestamp] * 1000;
auto modifiers = [self getModifiers:[event modifierFlags]];
@ -1749,6 +1762,24 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent
[super scrollWheel:event];
}
- (void)magnifyWithEvent:(NSEvent *)event
{
[self mouseEvent:event withType:Magnify];
[super magnifyWithEvent:event];
}
- (void)rotateWithEvent:(NSEvent *)event
{
[self mouseEvent:event withType:Rotate];
[super rotateWithEvent:event];
}
- (void)swipeWithEvent:(NSEvent *)event
{
[self mouseEvent:event withType:Swipe];
[super swipeWithEvent:event];
}
- (void)mouseEntered:(NSEvent *)event
{
_isMouseOver = true;

5
src/Avalonia.Native/avn.idl

@ -295,7 +295,10 @@ enum AvnRawMouseEventType
TouchBegin,
TouchUpdate,
TouchEnd,
TouchCancel
TouchCancel,
Magnify,
Rotate,
Swipe,
}
enum AvnRawKeyEventType

Loading…
Cancel
Save