Menus

By default, SigPlot provides a menu that is accessible via middle-click. From this menu the user can customize almost all aspects of the plot. To disable this menu, you can supply the 'nomenu' option when instantiating the plot.

plot = new sigplot.Plot(document.getElementById('plot'), {nomenu: true});

When the menu is disabled, a 'showmenu' event will be emitted. You can use this to provide a custom menu or take an alternate action. The event will include the 'x' and 'y' pixel location that can be used for displaying a menu.

plot.addListener("showmenu", function(event) {
  // Use a bootstrap dropdown menu as a popup
  $("#contextMenu").css({
	            display: "block",
	            left: event.x,
	            top: event.y,
	            zIndex: 99999 // ensure the menu is above all plot layers
	        });
  // optional...make the plot not respond to mouse events while the menu is
  // up
  plot.disable_listeners();
});

plot.addListener("hidemenu", function() {
  // If the plot wants us to hide the menu, do so now
  $("#contextMenu").hide();
});

$(document).on("click.contextmenu", function () {
  // handle menu clicks
	try {
    	$("#contextMenu").hide();
	} finally  {
	    // When you are done with the menu, renable the plot listeners
    	plot.enable_listeners();	
	}
	
	return false;
});