Невозможно получить значение mxcell для фигур при нажатии - PullRequest
0 голосов
/ 15 октября 2019

У меня есть mxWindow, в котором я создал график и добавил в него фигуры. когда нажата форма, я хочу получить ее значение mxcell.

Я приложил свой код ниже. Помимо этого я пытался использовать

graph.getModel() 
graph.getSelectionCell()

Но ни один из них не дал желаемого результата.

 var tb = document.createElement('div');
        var wnd = new mxWindow('Title', tb, 240, 240, 200, 200, true, true);
        wnd.setMaximizable(true);
        wnd.setResizable(true);
        wnd.setVisible(true);
        wnd.setClosable(true);
        var graphs = new mxGraph(tb);
        graphs.setTooltips(true);
        graphs.setPanning(true);
        graphs.setEnabled(false)
        var rubberband = new mxRubberband(graphs);
        new mxKeyHandler(graphs);
        mxEvent.disableContextMenu(tb);
        var parent = graphs.getDefaultParent();
        var v1,v2,v3,v4,v5,v6,v7,v8,v9
        graphs.getModel().beginUpdate();
       try
                {
                    v1 = graphs.insertVertex(parent, Editor.guid(), null , 20, 20, 50, 50, "shape=mxgraph.bpmn.shape;html=1;verticalLabelPosition=bottom;labelBackgroundColor=#ffffff;verticalAlign=top;align=center;perimeter=ellipsePerimeter;outlineConnect=0;outline=standard;symbol=general;");
                    v2 = graphs.insertVertex(parent, Editor.guid(), null , 80, 20, 50, 50, "shape=mxgraph.bpmn.shape;html=1;verticalLabelPosition=bottom;labelBackgroundColor=#ffffff;verticalAlign=top;align=center;perimeter=ellipsePerimeter;outlineConnect=0;outline=throwing;symbol=general;");
                    v3 = graphs.insertVertex(parent, Editor.guid(), null, 140, 20, 50,50, "shape=mxgraph.bpmn.shape;html=1;verticalLabelPosition=bottom;labelBackgroundColor=#ffffff;verticalAlign=top;align=center;perimeter=ellipsePerimeter;outlineConnect=0;outline=end;symbol=general;")
                    v4 = graphs.insertVertex(parent, Editor.guid(), null, 20, 80, 50,50, "shape=ext;rounded=1;html=1;whiteSpace=wrap;")
                    v5 = graphs.insertVertex(parent, Editor.guid(), null, 80, 80, 50,50, "shape=ext;rounded=1;html=1;whiteSpace=wrap;dashed=1;dashPattern=1 4;")
                    v6 = graphs.insertVertex(parent, Editor.guid(), null, 140, 80, 50,50, "html=1;whiteSpace=wrap;rounded=1;")
                    v7 = graphs.insertVertex(parent, Editor.guid(), null, 20, 140, 50,50, "html=1;shape=plus;outlineConnect=0;")
                    v8 = graphs.insertVertex(parent, Editor.guid(), null, 80, 140, 50,50, "shape=note;whiteSpace=wrap;size=16;html=1;")
                    v9 = graphs.insertVertex(parent, Editor.guid(), null, 140, 140, 50,50, "shape=mxgraph.bpmn.shape;html=1;verticalLabelPosition=bottom;labelBackgroundColor=#ffffff;verticalAlign=top;align=center;perimeter=rhombusPerimeter;background=gateway;outlineConnect=0;outline=none;symbol=general;")
                }
                finally
                {
                    // Updates the display
                    graphs.getModel().endUpdate();
                }
              graphs.addListener(mxEvent.CLICK, function(sender, evt)
                {
                    var cell = evt.getProperty('cell');
                    if(cell != null){
                        var th = graphs.mxCell.getStyle()
                    }                        
                    mxUtils.alert('click: '+((cell != null) ? th : 'Graph'));
                    evt.consume();
                });

Я хочу, чтобы результат был, когда нажата фигура, создайте переменнуюxx и сохраните в нем значение mxcell фигур.

...