private void OnContextualMenuPopulate(ContextualMenuPopulateEvent evt) { if (evt.target is NodeElement node) { evt.menu.AppendAction( "Add Edge", (DropdownMenuAction menuItem) => { m_Active = true; // 親をたどってGraphEditorElementを取得する m_Graph = target.GetFirstAncestorOfType <GraphEditorElement>(); m_ConnectingEdge = m_Graph.CreateEdgeElement(node, menuItem.eventInfo.mousePosition); target.CaptureMouse(); }, DropdownMenuAction.AlwaysEnabled); } }
private void OnContextualMenuPopulate(ContextualMenuPopulateEvent evt) { if (evt.target is NodeElement node) { if (!node.ContainsPoint(node.WorldToLocal(evt.mousePosition))) { evt.StopImmediatePropagation(); return; } evt.menu.AppendAction( "Add Edge", (DropdownMenuAction menuItem) => { m_Active = true; m_Graph = target.GetFirstAncestorOfType <GraphEditorElement>(); m_ConnectingEdge = m_Graph.CreateEdgeElement(node, menuItem.eventInfo.mousePosition); target.CaptureMouse(); }, DropdownMenuAction.AlwaysEnabled); } }