PDA

View Full Version : Ext.ux.ContextMenu



Xander75
14 Jan 2009, 3:39 AM
Hi all,

After searching through the forums for solutions on how to create Context Menu's, which there seemed to be many ways, but I couldn't find a User Extension. So I decided to create my first ever Ext extension for creating multiple Context Menu's that can be applied to any element that has an id.

The code is extremely lightweight and very simple to use. With this I have managed to create Context Menu's on all elements of the Ext Desktop application and any other webpage.

Feel free to use this in any project, any comments on this are appreciated.

P.S. This being my first user extension, be kind ;)

Update made to perform the eval() within the Ext.ux.ContextMenu

jsakalos
14 Jan 2009, 5:03 AM
This looks more like factory function than like extension.

A bit of theory of context menus:
The main purpose of context menu is to provide user a selection of operations that can be executed when he/she right clicks on a particular place, object of desktop. The offered items and their enabled/disabled state depend on where he/she clicked, on the object we're going to execute an operation on.

The main problem I can see with the code you posted is that it doesn't implement anything from this category, neither it respects context (the location of the click) nor it provides anything to adjust items visibility and/or enabled/disabled state of items.

For this reason, I do not see any difference between your "extension" and new Ext.menu.Menu() command.

Please, don't take me wrong, I do not want to discourage you in writing and publishing your work, many won't do so. Take my comment as ideas to make the context menu better.

We're missing a context menu in core Ext anyway, so go on and improve yours.

Xander75
14 Jan 2009, 5:12 AM
Thanks for the comments,

This was quickly made this morning from the code I had working in my application. The idea was to wrap this into an extension so this can be expanded on either by myself or others. I am fairly new to programming with the Ext framework and thought this might help in starting off a Context Menu extension control.

I will be looking into creating an enabled/disabled state shortly, currently I have not required this option.

jsakalos
14 Jan 2009, 5:21 AM
I've been using context menu in some of my extension, namely http://remotetree.extjs.eu and http://filetree.extjs.eu, so you can take a look at their behavior and code and to generalize it somehow to create a universal context menu class.