更多方案  |  文档  |  博客  |  支持库  |  论坛  |  关于   |  EN
如何实现按下Delete键弹出确认对话框?
作者:jeff  |  日期: 2015-05-04  |  人气: 2,990  |  分类: TWaver HTML5

network.setKeyboardRemoveEnabled(false);//先禁用默认的Delete操作:
//重新自定义键盘事件:
 network.getView().addEventListener("keydown", function (e) {
                if (e.keyCode === 46) {
                    deleteSelection();//your handle function
                }
            });

var deleteSelection = function(){
            var nodes = box.getSelectionModel().getSelection().toArray();
            if(nodes) {
                var message='Sure to Delete?';
                if(window.confirm(message)){
                    for(var i=0;i<nodes.length;i++){
                        var node = nodes[i];
                        box.remove(node);
                    }
                }
            }
        }


——TWaver开发组

返回支持库