I'm trying to create a menu based on the example code given on the wsh panel mod project page:
// vi:set ft=javascript ff=dos ts=4 sts=4 sw=4 et:
// Flags, used by Menu
var MF_SEPARATOR = 0x00000800;
var MF_ENABLED = 0x00000000;
var MF_GRAYED = 0x00000001;
var MF_DISABLED = 0x00000002;
var MF_UNCHECKED = 0x00000000;
var MF_CHECKED = 0x00000008;
var MF_STRING = 0x00000000;
var MF_POPUP = 0x00000010;
var MF_RIGHTJUSTIFY = 0x00004000;
// custom popup menu should always reponse to left-click
// This sample is more complex, because use fb2k's context menu manager to display system context menu
function on_mouse_lbtn_down(x, y) {
var _context = fb.CreateContextMenuManager();
var _basemenu = window.CreatePopupMenu();
var _child = window.CreatePopupMenu();
var ret;
// Please start index at 1, NOT 0
_basemenu.AppendMenuItem(MF_STRING, 1, "item1");
_basemenu.AppendMenuItem(MF_STRING, 2, "item2");
_basemenu.AppendMenuItem(MF_STRING | MF_POPUP, _child.ID, "Now Playing");
_context.InitNowPlaying();
_context.BuildMenu(_child, 3, -1);
ret = _basemenu.TrackPopupMenu(x, y);
// Here is why start index should be 0
if (ret == 0) return;
// Execute!
switch (ret) {
case 1:
fb.trace("Mmmm, you have choose item1, of course");
break; // break is important, or it will exucte the following...
case 2:
fb.trace("Ok, item2 is clicked");
break;
default:
_context.ExecuteByID(ret - 3);
fb.trace(ret.toString());
break;
}
_basemenu.Dispose();
}
I think I get the logic of the thing. 2 questions I have though are:
a) Is there any way to have the menu appear in the same place no matter where I click on the wsh panel? Ie if I always want to appear below the button rather than centered on the mouseclick?
b) In windows 7/vista theres a bar at the side of the menu where icons can appear (eg cut/paste icons). Is there any way to specify those icons for each item?