0

bf-menu中怎么添加元素 元素中添加点击事件图片描述

飘枫 1
2018-11-13 提问
1 个回答
0

1、jquery的引用

//左键的监听事件里面调用自己的功能
    app.addEventListener(Glodon.Bimface.Viewer.Viewer3DEvent.ComponentsSelectionChanged, function(objectData) {
                viewer.render();
                id=objectData.objectId;
                changeStatus(app);
})

//添加自己的功能
    function changeStatus(app){
        var contextMenuCallback= function() {
            app.getViewer().render();
            var obj=$("#doms");
            if(obj.length<0||obj.length==0) {
            var     domc = document.createElement('div');
            var doms = document.createElement('div');
            var domss = document.createElement('div');
            var domt = document.createElement('div');
            var domtt1 = document.createElement('div');
            var domtt2 = document.createElement('div');
                domss.append(domt);
                domss.append(domtt1);
                domss.append(domtt2);
                domc.append(domss);
                domc.append(doms);
                domc.addClass("bf-sub-menu");
                domc.id = "doms";

                doms.addClass("bf-menu-item user-item");
                doms.innerHTML = "施工状态";

                domss.addClass("bf-menu");

                domt.addClass("bf-menu-item user-item");
                domt.innerHTML = "已完工";
                domt.id="finish";

                domtt1.addClass("bf-menu-item user-item");
                domtt1.innerHTML = "施工中";
                domtt1.id="starting";

                domtt2.addClass("bf-menu-item user-item");
                domtt2.innerHTML = "延期";
                domtt2.id="yanqi";
                var oid=id;
                $(".bf-tree-toolbar").next().append(domc);
            }else{
                //$(".bf-tree-toolbar").next().append($("#doms"))
            }
            $("#finish").on("click",function(){
                var colorRed = new Glodon.Web.Graphics.Color(0,128,0,1);
                var arr = [id];
                app.getViewer().removeSelectedId(arr);
                app.getViewer().overrideComponentsColorById(arr, colorRed);
                app.getViewer().render();
            })
            $("#starting").on('click',function(){
                var colorRed = new Glodon.Web.Graphics.Color(255,255,0, 1);
                var arr = [id];
                app.getViewer().removeSelectedId(arr);
                app.getViewer().overrideComponentsColorById(arr, colorRed);
                app.render();
            })
            $("#yanqi").on("click",function(){
                var colorRed = new Glodon.Web.Graphics.Color(255, 0, 0, 1);
                var arr = [id];
                app.getViewer().removeSelectedId(arr);
                app.getViewer().overrideComponentsColorById(arr, colorRed);
                app.render();
            })
            $.each($(".user-item"),function(item){
                $(item).on("click",function(){
                    $(".bf-tree-toolbar").hide();
                })
            })
            //立即去除监听事件,否则会累加多遍
            app.removeEventListener(Glodon.Bimface.Viewer.Viewer3DEvent.ContextMenu, contextMenuCallback)
        }
        
        app.addEventListener(Glodon.Bimface.Viewer.Viewer3DEvent.ContextMenu, contextMenuCallback)
    }

clipboard.png

撰写答案

推广链接