@@ -57,6 +57,10 @@ import utils from '../../utils';
5757 * window.alert('Clicked node ${nodeId}');
5858 * };
5959 *
60+ * const onRightClickNode = function(event, nodeId) {
61+ * window.alert('Right clicked node ${nodeId}');
62+ * };
63+ *
6064 * const onMouseOverNode = function(nodeId) {
6165 * window.alert(`Mouse over node ${nodeId}`);
6266 * };
@@ -69,6 +73,10 @@ import utils from '../../utils';
6973 * window.alert(`Clicked link between ${source} and ${target}`);
7074 * };
7175 *
76+ * const onRightClickLink = function(event, source, target) {
77+ * window.alert('Right clicked link between ${source} and ${target}');
78+ * };
79+ *
7280 * const onMouseOverLink = function(source, target) {
7381 * window.alert(`Mouse over in link between ${source} and ${target}`);
7482 * };
@@ -83,7 +91,9 @@ import utils from '../../utils';
8391 * config={myConfig}
8492 * onClickGraph={onClickGraph}
8593 * onClickNode={onClickNode}
94+ * onRightClickNode={onRightClickNode}
8695 * onClickLink={onClickLink}
96+ * onRightClickLink={onRightClickLink}
8797 * onMouseOverNode={onMouseOverNode}
8898 * onMouseOutNode={onMouseOutNode}
8999 * onMouseOverLink={onMouseOverLink}
@@ -383,6 +393,16 @@ export default class Graph extends React.Component {
383393 this . props . onClickNode && this . props . onClickNode ( clickedNodeId ) ;
384394 } ;
385395
396+ /**
397+ * Calls the callback passed to the component.
398+ * @param {Object } event - the event object generated by the event.
399+ * @param {string } clickedNodeId - The id of the node where the click was performed.
400+ * @returns {undefined }
401+ */
402+ onRightClickNode = ( event , clickedNodeId ) => {
403+ this . props . onRightClickNode && this . props . onRightClickNode ( event , clickedNodeId ) ;
404+ } ;
405+
386406 /**
387407 * Calls the callback passed to the component.
388408 * @param {Object } e - The event of onClick handler.
@@ -405,13 +425,15 @@ export default class Graph extends React.Component {
405425 this . state . nodes ,
406426 {
407427 onClickNode : this . onClickNode ,
428+ onRightClickNode : this . onRightClickNode ,
408429 onMouseOverNode : this . onMouseOverNode ,
409430 onMouseOut : this . onMouseOutNode
410431 } ,
411432 this . state . d3Links ,
412433 this . state . links ,
413434 {
414435 onClickLink : this . props . onClickLink ,
436+ onRightClickLink : this . onRightClickLink ,
415437 onMouseOverLink : this . onMouseOverLink ,
416438 onMouseOutLink : this . onMouseOutLink
417439 } ,
0 commit comments