English 中文(简体)
习惯法中的“正文法”
原标题:Custom "context menu" in flex

我要加上一条与分界线分离的习俗,但可以确切地说明如何看待。 我需要的是:

<mx:List id="treeContextFile" visible="false" width="233" verticalScrollPolicy="off" includeInLayout="false">
        <mx:dataProvider>
            <mx:Array >
                <mx:String>Open</mx:String>
                <horizontal line here >
                <mx:String>Cut</mx:String>
                <mx:String>Copy</mx:String>
                <mx:String>Paste</mx:String>
                <horizontal line here >
                <mx:String>Rename</mx:String>
                <mx:String>Delete</mx:String>
                <horizontal line here >
                <mx:String>Properties</mx:String>
            </mx:Array>
        </mx:dataProvider>
    </mx:List>
最佳回答
问题回答

If you re talking about a true contextual menu (the ones that shows up on right click), you might want to use the ContextMenu and ContextMenuItems class.

Something like that (in a <mx:Script> block) :

    var cmiOpen  :ContextMenuItem = new ContextMenuItem( "Open" );
    var cmiCut   :ContextMenuItem = new ContextMenuItem( "Cut", true );
    var cmiCopy  :ContextMenuItem = new ContextMenuItem( "Copy" );
    var cmiPaste :ContextMenuItem = new ContextMenuItem( "Paste" );
    var cmiRename:ContextMenuItem = new ContextMenuItem( "Rename", true );
    var cmiDelete:ContextMenuItem = new ContextMenuItem( "Delete" );
    var cmiProps :ContextMenuItem = new ContextMenuItem( "Properties" );

    var cm:ContextMenu = new ContextMenu();
        cm.addItem( cmiOpen );
        cm.addItem( cmiCut );
        cm.addItem( cmiCopy );
        cm.addItem( cmiPaste );
        cm.addItem( cmiRename );
        cm.addItem( cmiDelete );
        cm.addItem( cmiProps );

    cmiOpen.addEventListener( ContextMenuEvent.MENU_ITEM_SELECT, openFunction );
    cmiCut.addEventListener( ContextMenuEvent.MENU_ITEM_SELECT, cutFunction );
    ...

    yourComponent.contextMenu = cm;




相关问题
Disable button tooltip in AS3

I want to disable the tooltip on certain buttons. The tooltip manager seems to be an all or nothing solution. Is it possible to disable the tooltip for just one or two buttons?

Multiple Remote call made simultenously

I was making multiple remote calls and they are done sequentially and when I am getting a result event back it s triggering calls to all the methods with ResultEvent as an argument . I am supposed to ...

Attaching a property to an event in Flex/AS3

I have a parameter that needs to be passed along with an event. After unsuccessful attempts to place it on the type by extending the class, I ve been advised in another SO question to write a custom ...

Clearing RSL in Cache

I have built a flex application which has a "main" project and it is assosciated with a few RSL s which are loaded and cached once i run my "main" application. The problem i am facing is that the ...

What s a good way of deserializing data into mock objects?

I m writing a mock backend service for my flex application. Because I will likely need to add/edit/modify the mock data over time, I d prefer not to generate the data in code like this: var mockData =...

AS3 try/catch out of memory

I m loading a few huge images on my flex/as3 app, but I can t manage to catch the error when the flash player runs out of memory. Here is the what I was thinking might work (I use ???? because i dont ...

热门标签