zoukankan      html  css  js  c++  java
  • flex中定制右键菜单

    一、将flex的所有右键屏蔽,并响应右键
    第一步:
    在swf 所在html页加如下内容:
    <script>
    function onNsRightClick(e){
    if(e.which == 3){
      ownerarea.openRightClick();
      e.stopPropagation();
    }
    return false;
    }

    function onIeRightClick(e){
    if(event.button > 1){
      ownerarea.openRightClick();
      parent.frames.location.replace('javascript: parent.falseframe');
    }
    return false;
    }


    if(navigator.appName == "Netscape"){
    document.captureEvents(Event.MOUSEDOWN);
    document.addEventListener("mousedown", onNsRightClick, true);
    }
    else{
    document.onmousedown=onIeRightClick;
    }

    </script>

    第二步:
    swf所在html文件中AC_FL_RunContent中增加
    "wmode", "opaque", 

    第三步:flex中
    <mx:Application creationComplete="init();" mouseOver="getMouseTarget(event)">
    <mx:Script>
    private var mouseTarget:DisplayObject;

    private function init(): void{
    ExternalInterface.addCallback("openRightClick", openRightClick);
    }

    function openRightClick():void
    {
    var e:MouseEvent = new MouseEvent(MouseEvent.MOUSE_DOWN, true, false, mouseTarget.mouseX, mouseTarget.mouseY);
    mouseTarget.dispatchEvent(e);
    }

    function getMouseTarget(event:MouseEvent):void
    {
       mouseTarget = DisplayObject(event.target);
    }

    function showMouseEvent(event){
    //通过event.buttonDown为true和flash可以得到左键点击或右键点击
    // 但加入菜单没有效果,需要再研究
    var menu: Menu = new Menu();
    menu = Menu.createMenu(null, buildMenu);
    menu.labelField = "@label";
    menu.show(10,10);
    }
    </mx:Script>
    <mx:XML format="e4x" id="buildMenu">
    <root>
    <menuitem label="新建">
    </menuitem>
    </root>
    </mx:XML>
    <mx:Image x="62" source="../images/info_btn.gif" id="baseDataBtn" bottom="0" mouseDown="showMouseEvent(event)"/>
    </mx:Application>
  • 相关阅读:
    GRUB引导Win8,Win7,Ubuntu
    The vim syntax of systemd unit file
    Win8蓝屏(WHEA_UNCORRECTABLE_ERROR)
    C#生成Excel
    IE中使用IFrame或Frameset导致session丢失的问题
    Apache 配置详解 ( 最好的 APACHE 配置教程 )
    关于(enctype="multipart/formdata") post 提交时中文乱码解决方案(使用jspsmartupload时)
    Java获取当前时间
    windows中定时操作(SetTimer函数用法)
    _RecordsetPtr的 open函数
  • 原文地址:https://www.cnblogs.com/nianshi/p/1774378.html
Copyright © 2011-2022 走看看