0
votes

If I show an ExtJS context menu on ExtJS panel after text selection, it hides or deselects the text selection or window selection. How can I keep the selection when the context menu is shown?

listeners: {
    afterrender: function(comp) {
        comp.getEl().on('contextmenu', function(e,src) {
            //stop default browser context menu appearing
            e.stopEvent();
            contextMenu = new Ext.menu.Menu({
                items: [{
                    text:    "Show On Map",
                    iconCls: 'map',
                    handler: function(a,b,c) {
                        alert(this.id);
                    }
                }]
            });
            contextMenu.showAt([e.getPageX(),e.getPageY()]);
        });
    }
}
1

1 Answers

0
votes
var contextMenu = Ext.create('Ext.menu.Menu', {
        items: [{
            id:'zoom',
            text: 'Zoom in',
            layout: {
                align: 'left'
            },
            handler: function() {
                alert('You clicked the Zoom in button!');
            }
        },
        {
            text: 'Zoom out',
            align: 'left'
        },
        {
            text: 'Add Marker',
            align: 'left'
        }
        ]

    });

    map.div.oncontextmenu = function noContextMenu(e) {
        if (OpenLayers.Event.isRightClick(e)){
            contextMenu.showAt(e);
        }
        return false; //cancel the right click of brower
    };