GithubHelp home page GithubHelp logo

Comments (10)

mubaidr avatar mubaidr commented on May 17, 2024

You mean context menu or application menu? Also which tutorial please?

from vue-electron-template.

jdounivers avatar jdounivers commented on May 17, 2024

I mean the context menu, this :
image
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.

mubaidr avatar mubaidr commented on May 17, 2024

This should work as expected. Can you share your complete code, please?

from vue-electron-template.

jdounivers avatar jdounivers commented on May 17, 2024

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.

mubaidr avatar mubaidr commented on May 17, 2024

Looks good to me, I will check and update you.

from vue-electron-template.

jdounivers avatar jdounivers commented on May 17, 2024

Thanks
and thanks for your quick answers

from vue-electron-template.

mubaidr avatar mubaidr commented on May 17, 2024

It works as expected for me.

Untitled

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.

jdounivers avatar jdounivers commented on May 17, 2024

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.

jdounivers avatar jdounivers commented on May 17, 2024

With frame : false the contextmenu doesn't work anymore

from vue-electron-template.

mubaidr avatar mubaidr commented on May 17, 2024

Then it must be electronjs implementation,nothing to do with this template.

from vue-electron-template.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.