Comments (10)
You mean context menu or application menu? Also which tutorial please?
from vue-electron-template.
I mean the context menu, this :
And i tried differents tutorials.
Doing this (as i saw in off doc) :
window.addEventListener('contextmenu', (e) => {
e.preventDefault()
menu.popup({ window: remote.getCurrentWindow() })
}, false)
or using electron-context-menu dependency
from vue-electron-template.
This should work as expected. Can you share your complete code, please?
from vue-electron-template.
I didn't change a lot of things.
Here is my src/renderer/main.js :
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)
}
})
}
from vue-electron-template.
Looks good to me, I will check and update you.
from vue-electron-template.
Thanks
and thanks for your quick answers
from vue-electron-template.
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
)
from vue-electron-template.
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
})
from vue-electron-template.
With frame : false
the contextmenu doesn't work anymore
from vue-electron-template.
Then it must be electronjs implementation,nothing to do with this template.
from vue-electron-template.
Related Issues (20)
- Update dependent packages? HOT 3
- lang=scss in vue single file component cause Module build failed HOT 2
- Vue 3 support?? HOT 1
- npm run pack:web failes with Module not found HOT 3
- Status of this project? HOT 3
- Add `--debug` flag support for production build
- Add build for web HOT 8
- Customizing app Icon from default HOT 2
- Question about workers HOT 1
- Include Express.js HOT 3
- Works well in dev mode, build successfully but can't launch after building. HOT 5
- console.log() not printing HOT 6
- trojan in node_modules... HOT 1
- Modify src/main causes multiple electron on reload HOT 9
- An unhandled error occurred inside electron-build HOT 2
- Using Typescript in vue components HOT 3
- Error when npm install HOT 2
- main process hot reload cause duplicated windows HOT 2
- Vue 3 support? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-electron-template.