summaryrefslogtreecommitdiff
path: root/platform/osx/src/MGLMapView.mm
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2016-05-09 00:17:22 -0700
committerMinh Nguyễn <mxn@1ec5.org>2016-05-09 00:17:22 -0700
commitdf1cae8d3a141a76432be798a3f34aeb2fc495e6 (patch)
tree694c4566d31580d2000741306090bcbbd747dc91 /platform/osx/src/MGLMapView.mm
parentc4b3c0142cfb127fb7d5c5f1c3ae666b2a225fd1 (diff)
downloadqtlocation-mapboxgl-df1cae8d3a141a76432be798a3f34aeb2fc495e6.tar.gz
[osx] Exclude subviews from click gestures
Fixes #3418.
Diffstat (limited to 'platform/osx/src/MGLMapView.mm')
-rw-r--r--platform/osx/src/MGLMapView.mm20
1 files changed, 18 insertions, 2 deletions
diff --git a/platform/osx/src/MGLMapView.mm b/platform/osx/src/MGLMapView.mm
index 741f0a7c02..e06086cf35 100644
--- a/platform/osx/src/MGLMapView.mm
+++ b/platform/osx/src/MGLMapView.mm
@@ -1344,7 +1344,8 @@ public:
/// Click or tap to select an annotation.
- (void)handleClickGesture:(NSClickGestureRecognizer *)gestureRecognizer {
- if (gestureRecognizer.state != NSGestureRecognizerStateEnded) {
+ if (gestureRecognizer.state != NSGestureRecognizerStateEnded
+ || [self subviewContainingGesture:gestureRecognizer]) {
return;
}
@@ -1375,7 +1376,8 @@ public:
/// Double-click or double-tap to zoom in.
- (void)handleDoubleClickGesture:(NSClickGestureRecognizer *)gestureRecognizer {
- if (!self.zoomEnabled || gestureRecognizer.state != NSGestureRecognizerStateEnded) {
+ if (!self.zoomEnabled || gestureRecognizer.state != NSGestureRecognizerStateEnded
+ || [self subviewContainingGesture:gestureRecognizer]) {
return;
}
@@ -1461,6 +1463,20 @@ public:
}
}
+/// Returns the subview that the gesture is located in.
+- (NSView *)subviewContainingGesture:(NSGestureRecognizer *)gestureRecognizer {
+ if (NSPointInRect([gestureRecognizer locationInView:self.compass], self.compass.bounds)) {
+ return self.compass;
+ }
+ if (NSPointInRect([gestureRecognizer locationInView:self.zoomControls], self.zoomControls.bounds)) {
+ return self.zoomControls;
+ }
+ if (NSPointInRect([gestureRecognizer locationInView:self.attributionView], self.attributionView.bounds)) {
+ return self.attributionView;
+ }
+ return nil;
+}
+
#pragma mark Keyboard events
- (void)keyDown:(NSEvent *)event {