JBR-2891: Post PhaseEvents in the begin and end of Magnify and Rotate

(cherry picked from commit c811c295c2)
(cherry picked from commit fe18b612dc)
This commit is contained in:
Denis Konoplev
2020-12-22 14:25:31 +03:00
committed by jbrbot
parent 0d51db361c
commit ecb42c8cb2

View File

@@ -143,21 +143,35 @@ AWT_NS_WINDOW_IMPLEMENTATION
}
}
- (void)beginGestureWithEvent:(NSEvent *)event {
[self postGesture:event
as:com_apple_eawt_event_GestureHandler_PHASE
a:-1.0
b:0.0];
}
- (BOOL)postPhaseEvent:(NSEvent *)event {
// Consider changing API to reflect MacOS api
// Gesture event should come with phase field
// PhaseEvent should be removed
const unsigned int NSEventPhaseBegan = 0x1 << 0;
const unsigned int NSEventPhaseEnded = 0x1 << 3;
const unsigned int NSEventPhaseCancelled = 0x1 << 4;
- (void)endGestureWithEvent:(NSEvent *)event {
[self postGesture:event
as:com_apple_eawt_event_GestureHandler_PHASE
a:1.0
b:0.0];
if (event.phase == NSEventPhaseBegan) {
[self postGesture:event
as:com_apple_eawt_event_GestureHandler_PHASE
a:-1.0
b:0.0];
return true;
} else if (event.phase == NSEventPhaseEnded ||
event.phase == NSEventPhaseCancelled) {
[self postGesture:event
as:com_apple_eawt_event_GestureHandler_PHASE
a:1.0
b:0.0];
return true;
}
return false;
}
- (void)magnifyWithEvent:(NSEvent *)event {
if ([self postPhaseEvent:event]) {
return;
}
[self postGesture:event
as:com_apple_eawt_event_GestureHandler_MAGNIFY
a:[event magnification]
@@ -165,6 +179,9 @@ AWT_NS_WINDOW_IMPLEMENTATION
}
- (void)rotateWithEvent:(NSEvent *)event {
if ([self postPhaseEvent:event]) {
return;
}
[self postGesture:event
as:com_apple_eawt_event_GestureHandler_ROTATE
a:[event rotation]