【问题标题】:How do you hidden/show particular context menu item in flex?您如何在 flex 中隐藏/显示特定的上下文菜单项?
【发布时间】:2010-04-26 06:55:41
【问题描述】:
    var contextMenu:ContextMenu = new ContextMenu();

        contextMenu.hideBuiltInItems();

        var contactList : ContextMenuItem = new ContextMenuItem("Add to Existing List");
        contactList.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, doStaticListCommand);

        var newContactList : ContextMenuItem = new ContextMenuItem("Add a New List");
        newContactList.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, doNewStaticListCommand); 

        var removeContactList : ContextMenuItem = new ContextMenuItem("Remove contact from List");
        removeContactList.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, doRemoveListCommand);

        var deletecontact:ContextMenuItem = new ContextMenuItem("Delete contact");
        deletecontact.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, dodeleteconactCommand);

        var TimeList : ContextMenuItem = new ContextMenuItem("Add Time Spent");
        TimeList.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, doTimeListCommand);

        contextMenu.customItems.push(contactList);      

        contextMenu.customItems.push(newContactList);           

        contextMenu.customItems.push(deletecontact);

         contextMenu.customItems.push(removeContactList);

在 flex 中,我完成了上下文菜单,如果我点击然后显示上下文菜单项,但我想在列表中隐藏特定的上下文菜单项,是否可以隐藏并在上下文菜单中显示特定的项目?请参考我,我尝试了基于键值的

if(Application.application.contact_key==1)
{
        contextMenu.customItems.push(deletecontact);
    }
        else 
    {

          contextMenu.customItems.push(removeContactList);
    }

        contextMenu.customItems.push(TimeList); 

        return contextMenu;

在 itemRenderer 中

contactListItemRenderer.as 上的所有编码,并像调用 datagrid 一样

 <mx:DataGridColumn  itemRenderer="com.view.Contact.ContactListItemRenderer"
                         dataField="fullName" headerText="Full Name" />

【问题讨论】:

    标签: apache-flex flash flex3 air adobe


    【解决方案1】:

    您可以通过 contextMenu.customItem 访问自定义菜单项并隐藏/显示任何特定项。对于内置菜单项,您可以访问 contextMenu.builtInItems(参见下面的代码):

            contextMenuCustom.builtInItems.zoom = false;
            contextMenuCustom.builtInItems.save = true;
    

    【讨论】:

    • 感谢Cornel Cranga先生的回复
    猜你喜欢
    • 2018-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-14
    • 2021-06-08
    相关资源
    最近更新 更多