From ccdef6d5de77da0d4437806b38322ee71ee2f3f2 Mon Sep 17 00:00:00 2001 From: Jan Jongboom Date: Sat, 16 Apr 2016 16:06:25 +0200 Subject: [PATCH] Add an option to disable the context menu --- app/src/components/mainWindow/mainWindow.js | 4 +++- docs/api.md | 12 ++++++++++-- src/build/buildApp.js | 3 ++- src/cli.js | 1 + src/options/optionsMain.js | 3 ++- 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/app/src/components/mainWindow/mainWindow.js b/app/src/components/mainWindow/mainWindow.js index 27e4085..4e39e0e 100644 --- a/app/src/components/mainWindow/mainWindow.js +++ b/app/src/components/mainWindow/mainWindow.js @@ -116,7 +116,9 @@ function createMainWindow(options, onAppQuit, setDockBadge) { }; createMenu(menuOptions); - initContextMenu(mainWindow); + if (!options.disableContextMenu) { + initContextMenu(mainWindow); + } if (options.userAgent) { mainWindow.webContents.setUserAgent(options.userAgent); diff --git a/docs/api.md b/docs/api.md index e9f2b5d..16cbb88 100644 --- a/docs/api.md +++ b/docs/api.md @@ -205,7 +205,7 @@ Forces the packaged app to ignore web security errors, such as [Mixed Content](h If `--flash` is specified, Nativefier will automatically try to determine the location of your Google Chrome flash binary. Take note that the version of Chrome on your computer should be the same as the version used by the version of Electron for the Nativefied package. -Take note that if this flag is specified, the `--insecure` flag will be added automatically, to prevent the Mixed Content errors on sites such as [Twitch.tv](https://www.twitch.tv/). +Take note that if this flag is specified, the `--insecure` flag will be added automatically, to prevent the Mixed Content errors on sites such as [Twitch.tv](https://www.twitch.tv/). #### [flash-path] @@ -213,7 +213,7 @@ Take note that if this flag is specified, the `--insecure` flag will be added au --flash-path ``` -You can also specify the path to the Chrome flash plugin directly with this flag. The path can be found at [chrome://plugins](chrome://plugins), under `Adobe Flash Player` > `Location`. This flag automatically enables the `--flash` flag as well. +You can also specify the path to the Chrome flash plugin directly with this flag. The path can be found at [chrome://plugins](chrome://plugins), under `Adobe Flash Player` > `Location`. This flag automatically enables the `--flash` flag as well. #### [inject] @@ -254,6 +254,14 @@ Makes the packaged app start maximized. Shows detailed logs in the console. +#### [disable-context-menu] + +``` +--disable-context-menu +``` + +Disable the context menu + ## Programmatic API You can use the Nativefier programmatic API as well. diff --git a/src/build/buildApp.js b/src/build/buildApp.js index afc7872..dc0f1e3 100644 --- a/src/build/buildApp.js +++ b/src/build/buildApp.js @@ -106,7 +106,8 @@ function selectAppArgs(options) { insecure: options.insecure, flashPluginDir: options.flashPluginDir, fullScreen: options.fullScreen, - maximize: options.maximize + maximize: options.maximize, + disableContextMenu: options.disableContextMenu }; } diff --git a/src/cli.js b/src/cli.js index c795d4f..00cbf1d 100755 --- a/src/cli.js +++ b/src/cli.js @@ -42,6 +42,7 @@ if (require.main === module) { .option('--full-screen', 'if the app should always be started in full screen') .option('--maximize', 'if the app should always be started maximized') .option('--verbose', 'if verbose logs should be displayed') + .option('--disable-context-menu', 'disable the context menu') .parse(process.argv); if (!process.argv.slice(2).length) { diff --git a/src/options/optionsMain.js b/src/options/optionsMain.js index df0f603..b835163 100644 --- a/src/options/optionsMain.js +++ b/src/options/optionsMain.js @@ -55,7 +55,8 @@ function optionsFactory(inpOptions, callback) { ignore: 'src', fullScreen: inpOptions.fullScreen || false, maximize: inpOptions.maximize || false, - verbose: inpOptions.verbose + verbose: inpOptions.verbose, + disableContextMenu: inpOptions.disableContextMenu }; if (options.verbose) {