Right Click Menu using React JS

后端 未结 2 430
死守一世寂寞
死守一世寂寞 2020-12-25 12:50

I\'d like to know if there is a best practice/correct way to setup a right-click menu for a React component.

I currently have this...

// nw is nw.gui         


        
2条回答
  •  粉色の甜心
    2020-12-25 13:32

    UPDATE:

    Figured it out - here is what you can do

    var addMenu;
    
    componentWillMount: function() {
        addMenu = new nw.Menu();
        addMenu.append(new nw.MenuItem({
            label: 'doSomething',
            click: function() {
                // doSomething
            }
        }));
    },
    
    contextMenu: function(e) {
        e.preventDefault();
        addMenu.popup(e.clientX, e.clientY);
    },
    
    render: function(){
        return 
    }
    

    In render you can pass a function to onContextMenu for when a right click occurs for this react component.

提交回复
热议问题