On 6/1/05, dillo_mac <[EMAIL PROTECTED]> wrote:
> Hello. I have the following code that gives me a right click on the
> main application. Is it possible to constrain this function to just
> once particular component like a grid?

You can save a reference to the old context menu and restore it
depending on where the right-click is happening.  I modified your code
to add a button that, when clicked, swaps between the two context
menus.

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml";
        xmlns="*" initialize="rightClick()">
        <mx:Script>
                var oldRootMenu;
function rightClick(){
                       var showItem = true;
                       var my_cm = new ContextMenu(menuHandler);
                       my_cm.customItems.push(new
ContextMenuItem("Hello", itemHandler));
                       my_cm.customItems.push(new
ContextMenuItem("Click Me", itemHandler));
                       my_cm.customItems.push(new
ContextMenuItem("Something", itemHandler));
                     my_cm.customItems.push(new
ContextMenuItem("Something else",
itemHandler));
                       my_cm.customItems.push(new
ContextMenuItem("Abcd", itemHandler));
                       my_cm.customItems.push(new
ContextMenuItem("1234", itemHandler));

                   function menuHandler(obj, menuObj) {
                     if (showItem == false) {
               menuObj.customItems[0].enabled = false;
                         } else {
               menuObj.customItems[0].enabled = true;
             }
           }
                                         function itemHandler(obj, item) {
                                }
                                 oldRootMenu = _root.menu;
         _root.menu = my_cm;

                                 }

                                 function swapRootMenu():Void
                                 {
                                         var temp = _root.menu;
                                         _root.menu = oldRootMenu;
                                         oldRootMenu = temp;
                                 }

                         </mx:Script>
                         <mx:Button label="Swap" click="swapRootMenu()" />
</mx:Application>


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to