Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: ExtJS 3.1.0: contextmenu and e.stopEvent in Firefox 3.6 (Mac Intel Leopard)

  1. #1

    Default ExtJS 3.1.0: contextmenu and e.stopEvent in Firefox 3.6 (Mac Intel Leopard)

    Edit: still the case under 3.1.1

    I've spent a bunch of time now searching the archives for instances where
    e.stopEvent is simply ignored, and found quite a few, but nothing exactly like this.

    I have a TreePanel and installed a listener for the contextmenu event.
    Initially I just threw in an e.stopEvent() in the handler, as per usual, but no go.

    So, I started trying various combinations, per the suggestions in various threads over the years.
    Just to satisfy myself, I've evolved the code to the following point:

    Code:
    	treePanel.on( 'contextmenu', function(node, e){
    		var el = node.getUI().getEl()
    		Ext.EventManager.addListener( el, 'contextmenu', function(e){
    			e.stopEvent();
    		}, null, { stopEvent: true } );
    		e.stopEvent();
    		alert("node: "+node.text);
    	}, this, { stopEvent: true })
    Yes, this is ridiculous, but even with all this, FF merrily presents me a context menu..

    Clues and hints gratefully solicited.
    --dan
    Last edited by dantheman; 9 Feb 2010 at 1:21 PM. Reason: saw 3.1.1 released and re-tested

  2. #2
    Ext JS Premium Member
    Join Date
    Dec 2009
    Posts
    58

    Thumbs up

    What are you trying to do ?
    me.constructor === Frontend.Engineer

  3. #3
    Sencha User realjax's Avatar
    Join Date
    Aug 2009
    Location
    Netherlands
    Posts
    412

    Default

    funny... I get the same behavior,

    BUT

    if you set an empty listener directly on the panel, like so:


    listeners: {
    contextmenu: function(){}
    }


    The event is stopped automatically..

  4. #4

    Default

    Quote Originally Posted by tot2ivn View Post
    What are you trying to do ?
    Handle a contextmenu event w/o the browser showing its contextmenu.

  5. #5

    Default

    Quote Originally Posted by realjax View Post
    funny... I get the same behavior,
    BUT
    if you set an empty listener directly on the panel, like so:
    listeners: {
    contextmenu: function(){}
    }
    The event is stopped automatically..
    I cannot replicate that. Either declaratively or installed post-creation.
    FF still shows its context menu.

  6. #6
    Ext JS Premium Member
    Join Date
    Dec 2009
    Posts
    58

    Thumbs up

    This is supposed to work in IE7, FF 3.6.. and other browsers:

    Code:
    new Ext.tree.TreePanel({
            listeners: {
                   render: function() {
                           Ext.getBody().on("contextmenu", Ext.emptyFn, null, {preventDefault: true});
                   }, 
                   contextmenu: function(e) {
                           // Your context menu
                   }
            }
    });
    Cheers

    Totti
    me.constructor === Frontend.Engineer

  7. #7

    Default

    Quote Originally Posted by tot2ivn View Post
    This is supposed to work in IE7, FF 3.6.. and other browsers:

    Code:
    new Ext.tree.TreePanel({
            listeners: {
                   render: function() {
                           Ext.getBody().on("contextmenu", Ext.emptyFn, null, {preventDefault: true});
                   }, 
                   contextmenu: function(e) {
                           // Your context menu
                   }
            }
    });
    Cheers

    Totti
    Totti,

    Thanks for the suggestion, but that's not the trick, at least in FF 3.6 on my mac.

    You say "supposed" .. where did you find this?

  8. #8

    Default Here's a simple test file, demonstrating the problem ...

    Code:
    <html><head>
    	<link rel=stylesheet href=/ext-3.1.1/resources/css/ext-all.css />
    
    	<script src="/ext-3.1.1/adapter/ext/ext-base.js"></script>
    	<script src="/ext-3.1.1/ext-all-debug.js"></script>
    
    <script>
    Ext.onReady(function(){
    
    	Ext.BLANK_IMAGE_URL = '/ext-3.1.1/resources/images/default/s.gif';
    	Ext.QuickTips.init();
    
    	var tree = new Ext.tree.TreePanel({
    		renderTo: 'tree-panel',
    		root: new Ext.tree.TreeNode({
    			id: 'tree-root',
    			expanded: true,
    			text: 'da root'
    		}),
    		listeners: {
    			render: function() {
    				Ext.getBody().on("contextmenu", Ext.emptyFn, null, {stopEvent: true});
    			},
    			contextmenu: function(node, e) {
    				e.stopEvent();
    				alert("node: "+node.text);
    			}
    		}
    	});
    	
    	tree.getRootNode().appendChild([{
    		id: 'child-one',
    		text: 'First Child'
    	},{
    		id: 'child-two',
    		text: 'Second Child'
    	},{
    		id: 'child-three',
    		text: 'Third Child'
    	}]);
    
    });
    </script>
    </head><body><div id='tree-panel'></div></body></html>
    Feel free to change the contextmenu listener handler to whatever scheme discussed above.
    None work.

    FWIW, a simple e.preventDefault used to work just fine for me, but I was targeting IE7 uniquely at the time ...

    If the idiom has changed, there is no discussion I can find on the board, and no reference in the documentation ...

    I've found bugs before (oddly, in Ext.tree), could this be a regression?

    --dan
    Last edited by dantheman; 11 Feb 2010 at 10:02 AM. Reason: chopped the IE-killing hanging comma after contextmenu handler :)

  9. #9
    Sencha User realjax's Avatar
    Join Date
    Aug 2009
    Location
    Netherlands
    Posts
    412

    Default

    Works fine here in ff 3.5.7 (even without the 'e.stopEvent();') on Vista, the contextmenu is not shown...

  10. #10
    Ext JS Premium Member
    Join Date
    Dec 2009
    Posts
    58

    Thumbs up

    dan, I did this trick in one of my projects with GridPanel. Tested working with TreePanel on FF 3.6, and IE 7.

    You probably could try testing with the ExtJs samples coming in the download package to see.


    Totti
    me.constructor === Frontend.Engineer

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •