-
-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable or customize Context menu #682
Comments
You mean context menu or application menu? Also which tutorial please? |
I mean the context menu, this : window.addEventListener('contextmenu', (e) => {
e.preventDefault()
menu.popup({ window: remote.getCurrentWindow() })
}, false) or using electron-context-menu dependency |
This should work as expected. Can you share your complete code, please? |
I didn't change a lot of things. import Vue from 'vue'
import App from './App.vue'
import './assets/style/main.scss'
import router from './router/index'
import store from './store/index'
const { remote } = require('electron')
const { Menu, MenuItem } = remote
const isDev = process.env.NODE_ENV === 'development'
Vue.config.devtools = isDev
Vue.config.performance = isDev
Vue.config.productionTip = isDev
// tslint:disable-next-line: no-unused-expression
new Vue({
el: '#app',
router,
store,
render: h => h(App),
})
const menu = new Menu()
menu.append(new MenuItem({ type: 'separator' }))
window.addEventListener('contextmenu', (e) => {
e.preventDefault()
menu.popup({ window: remote.getCurrentWindow() })
}, false)
// to avoild accesing electorn api from web app build
if (window && window.process && window.process.type === 'renderer') {
const { ipcRenderer } = require('electron')
// handle menu event updates from main script
ipcRenderer.on('change-view', (event, data) => {
if (data.route) {
router.push(data.route)
}
})
} |
Looks good to me, I will check and update you. |
Thanks |
It works as expected for me. Code sample used: const { remote } = require('electron')
const { Menu, MenuItem } = remote
const menu = new Menu()
menu.append(new MenuItem({ label: 'Home' }))
menu.append(new MenuItem({ type: 'separator' }))
menu.append(new MenuItem({ label: 'Other' }))
window.addEventListener(
'contextmenu',
(e) => {
e.preventDefault()
menu.popup({ window: remote.getCurrentWindow() })
},
false
) |
I saw where is the difference : mainWindow = new BrowserWindow({
backgroundColor: '#fff',
width: 960,
height: 540,
minWidth: 960,
minHeight: 540,
// useContentSize: true,
webPreferences: {
nodeIntegration: true,
nodeIntegrationInWorker: false,
webSecurity: false,
},
frame: false,
show: false,
resizable: false
}) |
With |
Then it must be electronjs implementation,nothing to do with this template. |
Hello,
I'm trying to disable or change the context menu but everything i saw on tutoriel doesn't seems to work.
Is there a specific way to change it with this template ?
The text was updated successfully, but these errors were encountered: