Context/Tools Menus
I am continuing to work on my web interface to ISPF and one of the things I wanted to do was add popup tool menus to things like data set and PDS member lists. I found a couple of nice examples on the web but they either broke my web page or I was just not happy with them. So I tried to create my own. Fail! A lot of work and it really was not what I wanted. I guess I ‘could’ write a jQuery plugin to do it but in the end I found this, somewhat old but perfectly adequate example:
http://www.trendskitchens.co.nz/jquery/contextmenu/
The only problem I had was that it only worked for a ‘right click’ and I wanted it to work for a left click. After starting at it for hours I realized that it it is ‘this’ piece of code (the bind in fact) that controls the popup:
$(this).bind('contextmenu', function(e) {
// Check if onContextMenu() defined
var bShowContext = (!!hash[index].onContextMenu) ? hash[index].onContextMenu(e) : true;
if (bShowContext) display(index, this, e, options);
return false;
});
In fact, it is the ‘contexmenu’ event that controls it. So I changed that line to read like this:
$(this).bind('contextmenu click', function(e) {
And voila, I get the popup menu with both a left and a right click:
Now on to making the tools actually do something….

It looks great!