1. #1
    Sencha User SlashEMc2k's Avatar
    Join Date
    Jul 2007
    Posts
    84
    Vote Rating
    0
    SlashEMc2k is on a distinguished road

      0  

    Default on Viewport only show context menu?

    on Viewport only show context menu?


    I`m having problems setting up a context menu on the Ext.Viewport.
    When I use the code below, the context menu appears even if I right click on an Ext.Window

    Is this down to the scope on the onclick?
    Or do I need to setup a condition in the onContextMenu function, if viewport clicked then show context menu?


    Code:
    var bgBody = new Ext.Viewport({
    	id:'bgBody',
    	margins: '5 5 5 0',
    	layout:'fit',
    	items: iconDisplay
    });
    			
    //set on right click show context menu
    Ext.getCmp('bgBody').getEl().on('contextmenu', onContextMenu);
    //Ext.getBody().on('contextmenu', onContextMenu);
    
    function onContextMenu(e, target) {
    	e.preventDefault();
    	messageContextMenu.showAt(e.getXY());
    }

  2. #2
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,496
    Vote Rating
    44
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    The viewport encapsulates the document body, so all right clicks bubble up to it.

    You will have to use the Viewport's body

  3. #3
    Sencha User SlashEMc2k's Avatar
    Join Date
    Jul 2007
    Posts
    84
    Vote Rating
    0
    SlashEMc2k is on a distinguished road

      0  

    Default


    Thanks Animal,

    I've been reading through the API and I`m not sure how to get the viewports body?

    Do I just need to grab the first child of the body, as I can't reference it by its id as this is automatically generated?

Thread Participants: 1