I'm trying to modify sample script with the context menu button - I made the context menu appear on hover, but is there a way to hide it when I stop hovering over the button?
You will notice even the native foobar buttons/menus don't work while there is a menu open. The entire UI waits tracking the menu. There is no way to change it, unless the actual SMP code is changed.
Only the main menus work different (hovering as you said), but they hide when you hover over other main menu. If you move the mouse over other buttons or UI elements the menu remains there.
Ah, that's unfortunate, thank you very much for your reply.
Anyway, I've been studying javascript and now after 15 years of dreaming to modify foobar2000 myself I've started meddling with sample scripts. So I hope someone will be able to assist me in my newbie issues.
1 - I'm trying to create a general track info panel by combining several samples, for example TrackInfo Follows Cursor and Rating.
In rating component there's ability to switch between follow playback and follow cursor.
in the included file panel.js there's a function
function _panel(custom_background = false) {
this.item_focus_change = () => {
if (this.metadb_func) {
if (this.selection.value == 0) {
this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
} else {
this.metadb = fb.GetFocusItem();
}
on_metadb_changed();
if (!this.metadb) {
_tt('');
}
}
}
I don't see where and how the result is stored in the rating sample script so I am having issues assigning handle to a customizable option (from general track info - let handle = fb.GetFocusItem()
2 - in sample custom context menu how can I modified stuff so that there's a specific area where I want to click (hover, actually, but oh well) which acts as a button.
gr.DrawImage(img, 340, 200, img.Width, img.Height, 0, 0, img.Width, img.Height);
function menu() {
let _context = fb.CreateContextMenuManager();
let _basemenu = window.CreatePopupMenu();
let _child = window.CreatePopupMenu();
// start index at 1, NOT 0
_basemenu.AppendMenuItem(MF_STRING, 1, "Open facets");
_basemenu.AppendMenuItem(MF_STRING, 2, 'item2');
if (fb.GetNowPlaying()) {
_child.AppendTo(_basemenu, MF_STRING, 'Now Playing');
}
_context.InitNowPlaying();
_context.BuildMenu(_child, 3);
const idx = _basemenu.TrackPopupMenu(1, 4);
switch (idx) {
case 0: //user dismissed menu by clicking elsewhere.
break;
case 1:
fb.RunMainMenuCommand("Library/Facets");
break;
case 2:
fb.ShowPopupMessage('OK, item2 is clicked.');
break;
default:
_context.ExecuteByID(idx - 3);
break;
}}
function on_mouse_lbtn_up(x, y) {
if (x > 350 && x < 370 && y > 200 && y < 240) {
menu();
}
rating.lbtn_up(x, y);
}
How do I make the context menu open at specific coordinates? Right now it opens at 0,0.
3 - how can I add an onclick function to a simple text line? like on this one gr.GdiDrawText("foobar2000", gdi.Font('Product Sans', 36, 1), RGB(245,245,245), 0, 0, window.Width, 30, DT_VCENTER | DT_CENTER | DT_END_ELLIPSIS | DT_CALCRECT | DT_NOPREFIX);