[macos] Avoid first responder action name conflict
Fixed a crash that often occurred when switching styles. MGLMapView was ahead of MapDocument in the responder chain, so calls to -setStyle: were going to MGLMapView’s private -setStyle: method. The sender was being passed in the first parameter instead of an MGLStyle method.
This commit is contained in:
committed by
Minh Nguyễn
parent
9fac640bf3
commit
03a2dbe361
@@ -366,32 +366,32 @@
|
||||
<items>
|
||||
<menuItem title="Streets" state="on" tag="1" keyEquivalent="1" id="17N-yz-NNo">
|
||||
<connections>
|
||||
<action selector="setStyle:" target="-1" id="I4L-Wx-UXA"/>
|
||||
<action selector="showStyle:" target="-1" id="BGu-va-ftr"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Outdoors" tag="2" keyEquivalent="2" id="BBa-Qa-SQr">
|
||||
<connections>
|
||||
<action selector="setStyle:" target="-1" id="rM1-yG-t5u"/>
|
||||
<action selector="showStyle:" target="-1" id="sQ3-b6-G1A"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Light" tag="3" keyEquivalent="3" id="HWe-7u-UVJ">
|
||||
<connections>
|
||||
<action selector="setStyle:" target="-1" id="Q9V-O1-oRz"/>
|
||||
<action selector="showStyle:" target="-1" id="jMN-oR-sbZ"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Dark" tag="4" keyEquivalent="4" id="6HI-q6-AeV">
|
||||
<connections>
|
||||
<action selector="setStyle:" target="-1" id="YfH-1I-G50"/>
|
||||
<action selector="showStyle:" target="-1" id="xgf-Sq-eJw"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Satellite" tag="5" keyEquivalent="5" id="h0J-5X-kgF">
|
||||
<connections>
|
||||
<action selector="setStyle:" target="-1" id="GXt-oK-Hy1"/>
|
||||
<action selector="showStyle:" target="-1" id="YyE-2C-Vhj"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Satellite Streets" tag="6" keyEquivalent="6" id="9BL-00-HFt">
|
||||
<connections>
|
||||
<action selector="setStyle:" target="-1" id="oL4-AC-waq"/>
|
||||
<action selector="showStyle:" target="-1" id="NTT-Y1-EqU"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Custom Style…" id="L0h-86-2cU">
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
</popUpButtonCell>
|
||||
</popUpButton>
|
||||
<connections>
|
||||
<action selector="setStyle:" target="-1" id="2Kw-9i-a3G"/>
|
||||
<action selector="showStyle:" target="-1" id="pBn-SO-HIX"/>
|
||||
</connections>
|
||||
</toolbarItem>
|
||||
</allowedToolbarItems>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
@property (weak) IBOutlet MGLMapView *mapView;
|
||||
|
||||
- (IBAction)setStyle:(id)sender;
|
||||
- (IBAction)showStyle:(id)sender;
|
||||
- (IBAction)chooseCustomStyle:(id)sender;
|
||||
|
||||
- (IBAction)reload:(id)sender;
|
||||
|
||||
@@ -143,7 +143,7 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio
|
||||
|
||||
#pragma mark View methods
|
||||
|
||||
- (IBAction)setStyle:(id)sender {
|
||||
- (IBAction)showStyle:(id)sender {
|
||||
NSInteger tag;
|
||||
if ([sender isKindOfClass:[NSMenuItem class]]) {
|
||||
tag = [sender tag];
|
||||
@@ -563,7 +563,7 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio
|
||||
#pragma mark User interface validation
|
||||
|
||||
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem {
|
||||
if (menuItem.action == @selector(setStyle:)) {
|
||||
if (menuItem.action == @selector(showStyle:)) {
|
||||
NSURL *styleURL = self.mapView.styleURL;
|
||||
NSCellStateValue state;
|
||||
switch (menuItem.tag) {
|
||||
@@ -731,7 +731,7 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio
|
||||
return ([styleURL.scheme isEqualToString:@"mapbox"]
|
||||
&& [styleURL.pathComponents.firstObject isEqualToString:@"styles"]);
|
||||
}
|
||||
if (toolbarItem.action == @selector(setStyle:)) {
|
||||
if (toolbarItem.action == @selector(showStyle:)) {
|
||||
NSPopUpButton *popUpButton = (NSPopUpButton *)toolbarItem.view;
|
||||
NSUInteger index = self.indexOfStyleInToolbarItem;
|
||||
if (index == NSNotFound) {
|
||||
|
||||
Reference in New Issue
Block a user