branchseer / DeskGap

A cross-platform desktop app framework based on Node.js and the system webview
https://deskgap.com/
MIT License
1.83k stars 75 forks source link

click action not fired in MenuItem #52

Open mdings opened 4 years ago

mdings commented 4 years ago

In my javascript file I use the code below to trigger a context menu. Notice that I used two different methods to trigger the click, however none of them work. The context menu is displaying as it should btw, just the click handlers are not triggered. How should this be done?

    const asyncDeskgap = deskgap.asyncNode
    const curWin = asyncDeskgap.getCurrentWindow()
    asyncDeskgap.require('deskgap').then(deskgap => {
        deskgap.prop('Menu')
            .invoke('buildFromTemplate', 
                [{ 
                    'label': 'label one', 
                    onClick() {
                        console.log('click')
                    } 
                }, {
                    'type': 'separator'
                }, { 
                    'label': 'label two', 
                    click() {
                        console.log('k do this')
                    } 
                }])
            .invoke('popup', curWin).value()
    })