mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 22:55:48 +01:00
Disable context menu in production mode
This commit is contained in:
parent
bc260b08b2
commit
40fdf75042
4 changed files with 18 additions and 4 deletions
|
|
@ -113,8 +113,6 @@ func (a *Application) Run(incomingDispatcher Dispatcher, bindings string, debug
|
|||
fullscreen := a.bool2Cint(a.config.Fullscreen)
|
||||
startHidden := a.bool2Cint(a.config.StartHidden)
|
||||
logLevel := C.int(a.config.LogLevel)
|
||||
println("debug = ", debug)
|
||||
println("devtools = ", a.config.DevTools)
|
||||
app := C.NewApplication(title, width, height, resizable, devtools, fullscreen, startHidden, logLevel)
|
||||
|
||||
// Save app reference
|
||||
|
|
|
|||
|
|
@ -1016,6 +1016,13 @@ void Run(struct Application *app, int argc, char **argv) {
|
|||
index++;
|
||||
};
|
||||
|
||||
// Disable context menu if not in debug mode
|
||||
if( debug != 1 ) {
|
||||
temp = concat(internalCode, "wails._.DisableContextMenu();");
|
||||
free((void*)internalCode);
|
||||
internalCode = temp;
|
||||
}
|
||||
|
||||
// class_addMethod(delegateClass, s("applicationWillFinishLaunching:"), (IMP) willFinishLaunching, "@@:@");
|
||||
// Include callback after evaluation
|
||||
temp = concat(internalCode, "webkit.messageHandlers.completed.postMessage(true);");
|
||||
|
|
@ -1024,7 +1031,7 @@ void Run(struct Application *app, int argc, char **argv) {
|
|||
|
||||
// const char *viewportScriptString = "var meta = document.createElement('meta'); meta.setAttribute('name', 'viewport'); meta.setAttribute('content', 'width=device-width'); meta.setAttribute('initial-scale', '1.0'); meta.setAttribute('maximum-scale', '1.0'); meta.setAttribute('minimum-scale', '1.0'); meta.setAttribute('user-scalable', 'no'); document.getElementsByTagName('head')[0].appendChild(meta);";
|
||||
// ExecJS(app, viewportScriptString);
|
||||
|
||||
|
||||
|
||||
// This evaluates the MOAE once the Dom has finished loading
|
||||
msg(manager,
|
||||
|
|
@ -1035,6 +1042,8 @@ void Run(struct Application *app, int argc, char **argv) {
|
|||
1,
|
||||
1));
|
||||
|
||||
|
||||
|
||||
if( app->webviewIsTranparent == 1 ) {
|
||||
msg(wkwebview, s("setValue:forKey:"), msg(c("NSNumber"), s("numberWithBool:"), 0), str("drawsBackground"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import * as Window from './window';
|
|||
import * as Dialog from './dialog';
|
||||
import { On, Once, OnMultiple, Emit, Notify } from './events';
|
||||
import { Callback, SystemCall } from './calls';
|
||||
import { AddScript, InjectCSS } from './utils';
|
||||
import { AddScript, InjectCSS, DisableContextMenu } from './utils';
|
||||
import { AddIPCListener } from 'ipc';
|
||||
import * as Platform from 'platform';
|
||||
import * as Store from './store';
|
||||
|
|
@ -41,6 +41,7 @@ export function Init() {
|
|||
Notify,
|
||||
AddScript,
|
||||
InjectCSS,
|
||||
DisableContextMenu,
|
||||
// Init,
|
||||
AddIPCListener,
|
||||
SystemCall,
|
||||
|
|
|
|||
|
|
@ -36,3 +36,9 @@ export function InjectCSS(css) {
|
|||
console.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
export function DisableContextMenu() {
|
||||
AddScript('function contextMenu(event) { event.preventDefault(); }');
|
||||
var body = document.getElementsByTagName('body')[0];
|
||||
body.setAttribute('oncontextmenu', 'contextMenu(event)');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue