PDA

View Full Version : JsonView + contextmenu



alanwilliamson
29 Apr 2007, 9:45 AM
I am having some 'fun' with the contextmenu event.

I have successfully added a pop up menu to my JsonView, replacing the god-awful YUI context menu with the Ext menu. Slowly moving YUI dependency away from my code! :)

However, I have hit a small snag that i am sure someone has the answer to.

How do I disable the browsers default right-hand popup? At the moment it is displaying over the top of the new menu that is created.

Thanks

neongrau
29 Apr 2007, 9:51 AM
normally it is disabled, but IIRC when using ext-all-debug.js instead of ext-all.js the menu will still work.

try again without the debug version and it should work as expected.

alanwilliamson
29 Apr 2007, 10:07 AM
I wasn't using the debug version. I am using the latest public release. :(

72
29 Apr 2007, 11:38 AM
If you are using Firefox check Javascript preferences. TOOLS->PREFERENCES->CONTENT, -- checkbox Enable Javascript - nearby there is a button like Advanced.. -- in opened dialog there is something about DISABLE CONTEXT MENU=="this have to be checked" or similar (i don't know exact label and button names cause im using czech version of FF...translate yourself ;)

Hope it helps

dfenwick
29 Apr 2007, 1:01 PM
I am having some 'fun' with the contextmenu event.

I have successfully added a pop up menu to my JsonView, replacing the god-awful YUI context menu with the Ext menu. Slowly moving YUI dependency away from my code! :)

However, I have hit a small snag that i am sure someone has the answer to.

How do I disable the browsers default right-hand popup? At the moment it is displaying over the top of the new menu that is created.

Thanks

When you're hooking an event you get an EventObject back as a parameter for that event. In the handler, just stop the event. The elements in your app have a 'contextmenu' event defined for them. So you can do this:


Ext.get('my-menu-anchor').on('contextmenu', function(e, t) {
// e is the EventObject, t is the Target
e.stopEvent();
// alert(t.id + ' was clicked'); - Uncomment this for testing if you want
var coords = e.getXY();
myContextMenu.showAt([coords[0], coords[1]]);
});

alanwilliamson
29 Apr 2007, 10:05 PM
Perfect dfenwick, the "stopEvent" is our winner.

Thank you for your fast response.

JeffBurr
12 May 2007, 5:59 AM
Would you consider posting an example of your successful context menu on a JSONView. I am trying to do the same thing and can't seem to get the firing right.

Thanks in advance!

jsakalos
12 May 2007, 8:10 AM
Look at this thread I've posted some context menu code there. That code is not modified to be a sample so understanding can be harder but I think it can help.

http://extjs.com/forum/showthread.php?t=6042