Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

206
Views
¿Cómo crear un menú contextual en mxGraph cuando se hace clic en el lienzo (celda nula)?

En mi aplicación que usa mxGraph, tengo una función que habilita un menú contextual cuando se hace clic en una celda y devuelve diferentes opciones según el lugar donde se hace clic: borde o vértice. Mi código se ve así:

 graph.popupMenuHandler.factoryMethod = function (menu, cell, evt) { if (cell.edge) { menu.addItem("First edge option", null, function () { alert("This is the first option of edge "); }); menu.addItem("Second edge option", null, function () { alert("This is the second option of edge "); }); } if (cell.vertex) { menu.addItem("View Properties", null, function () { document.getElementById("property-panel").style["display"] = "block"; }); menu.addItem("View Measurements ", null, function () { if (cell.measurementName!= null) { openPopup(cell); } else { showAlert("This component does not have any plots!"); } }); } };

Esto funciona muy bien, pero quiero poder hacer clic derecho en el lienzo en blanco que no es una celda, es decir, en algún lugar del editor, pero que no contiene ningún vértice o borde. El problema con eso es que este método funciona solo cuando se hace clic en una celda, ya que sus parámetros son menu , cell y evt . Dado que no hay una celda en un lienzo en blanco, da el siguiente error: Uncaught TypeError: cell is null . ¿Alguien sabe si hay una mejor implementación, si hay un enfoque en el que podría crear una celda vacía (invisible) cuando el usuario hace clic con el botón derecho y luego activa el menú contextual pasando la celda invisible?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!