• 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>
  • 相关阅读:
    多线程学习纪要
    字符编码ASCII、Unicode、UTF-8以及验证
    C# 自定义特性Attribute要点
    Java --- 流操作
    数据库 --- 索引
    Java -- 枚举
    mybatis --- 使用通用mapper或者mybatis-plus进行映射时,当数据库中有大写字母,自定义映射的字段名。
    后端 --- 快速创建一个sb项目 (使用spring官网的https://start.spring.io)
    数据库 --- decimal类型测试
    Java --- 线上故障调优01 打印堆栈信息
  • 原文地址:https://www.cnblogs.com/nianshi/p/1774378.html
Copyright © 2020-2023  润新知