Skip to content

Commit

Permalink
[macOS] Add back the right click dev menu (facebook#1822)
Browse files Browse the repository at this point in the history
  • Loading branch information
Saadnajmi authored May 10, 2023
1 parent cf399b4 commit 97ad878
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Libraries/NativeModules/specs/NativeDevSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export interface Spec extends TurboModule {

// iOS only.
+setIsShakeToShowDevMenuEnabled: (enabled: boolean) => void;

// macOS only.
+setIsSecondaryClickToShowDevMenuEnabled: (enabled: boolean) => void; // [macOS]
}

export default (TurboModuleRegistry.getEnforcing<Spec>('DevSettings'): Spec);
14 changes: 14 additions & 0 deletions React/CoreModules/RCTDevSettings.mm
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
static NSString *const kRCTDevSettingExecutorOverrideClass = @"executor-override";
static NSString *const kRCTDevSettingShakeToShowDevMenu = @"shakeToShow";
static NSString *const kRCTDevSettingIsPerfMonitorShown = @"RCTPerfMonitorKey";
static NSString *const kRCTDevSettingSecondClickToShowDevMenu = @"secondClickToShow"; // [macOS]

static NSString *const kRCTDevSettingsUserDefaultsKey = @"RCTDevMenu";

Expand Down Expand Up @@ -157,6 +158,7 @@ - (instancetype)init
NSDictionary *defaultValues = @{
kRCTDevSettingShakeToShowDevMenu : @YES,
kRCTDevSettingHotLoadingEnabled : @YES,
kRCTDevSettingSecondClickToShowDevMenu: @YES, // [macOS]
};
RCTDevSettingsUserDefaultsDataSource *dataSource =
[[RCTDevSettingsUserDefaultsDataSource alloc] initWithDefaultValues:defaultValues];
Expand Down Expand Up @@ -332,6 +334,18 @@ - (BOOL)isShakeToShowDevMenuEnabled
return [[self settingForKey:kRCTDevSettingShakeToShowDevMenu] boolValue];
}

// [macOS
RCT_EXPORT_METHOD(setIsSecondaryClickToShowDevMenuEnabled:(BOOL)enabled)
{
[self _updateSettingWithValue:@(enabled) forKey:kRCTDevSettingSecondClickToShowDevMenu];
}

- (BOOL)isSecondaryClickToShowDevMenuEnabled
{
return [[self settingForKey:kRCTDevSettingSecondClickToShowDevMenu] boolValue];
}
// macOS]

RCT_EXPORT_METHOD(setIsDebuggingRemotely:(BOOL)enabled)
{
[self _updateSettingWithValue:@(enabled) forKey:kRCTDevSettingIsDebuggingRemotely];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ public void setIsShakeToShowDevMenuEnabled(boolean enabled) {
// iOS only
}

// [macOS
@Override
public void setIsShakeToShowDevMenuEnabled(boolean enabled) {
// macOS only
}
// macOS]

@Override
public void addListener(String eventName) {
// iOS only
Expand Down

0 comments on commit 97ad878

Please sign in to comment.