diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2016-05-09 00:17:22 -0700 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2016-05-09 00:17:22 -0700 |
commit | df1cae8d3a141a76432be798a3f34aeb2fc495e6 (patch) | |
tree | 694c4566d31580d2000741306090bcbbd747dc91 /platform | |
parent | c4b3c0142cfb127fb7d5c5f1c3ae666b2a225fd1 (diff) | |
download | qtlocation-mapboxgl-df1cae8d3a141a76432be798a3f34aeb2fc495e6.tar.gz |
[osx] Exclude subviews from click gestures
Fixes #3418.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/osx/app/MapDocument.m | 6 | ||||
-rw-r--r-- | platform/osx/src/MGLMapView.mm | 20 |
2 files changed, 23 insertions, 3 deletions
diff --git a/platform/osx/app/MapDocument.m b/platform/osx/app/MapDocument.m index bc692ba213..c75e1d68c7 100644 --- a/platform/osx/app/MapDocument.m +++ b/platform/osx/app/MapDocument.m @@ -405,7 +405,11 @@ static const CLLocationCoordinate2D WorldTourDestinations[] = { - (void)handlePressGesture:(NSPressGestureRecognizer *)gestureRecognizer { if (gestureRecognizer.state == NSGestureRecognizerStateBegan) { NSPoint location = [gestureRecognizer locationInView:self.mapView]; - [self dropPinAtPoint:location]; + if (!NSPointInRect([gestureRecognizer locationInView:self.mapView.compass], self.mapView.compass.bounds) + && !NSPointInRect([gestureRecognizer locationInView:self.mapView.zoomControls], self.mapView.zoomControls.bounds) + && !NSPointInRect([gestureRecognizer locationInView:self.mapView.attributionView], self.mapView.attributionView.bounds)) { + [self dropPinAtPoint:location]; + } } } 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 { |