- "Moving" tracks to a playlist item at the panel.
(Spider Monkey Panel specific) All mouse callbacks are suppressed during drag operation (including on_mouse_lbtn_up, but excluding on_mouse_mbtn_up and on_mouse_rbtn_up).
But according to the documentation, I can not track the mouse movement within the panel (?) to check the index the mouse is over. So judging the dragndrop sample I should use on_drag_enter() , etc. with the same functions I already have at on_mouse_move(x, y) to check the index I'm over, and then link that index to the handles I drop. Right?
Yes, on_mouse_move is replaced with on_drag_over.
Well I looked at it again and maybe I miss something but that part can not be done too. The drag n drop sample just redirects the action to another playlist by Id.
I can drop tracks to a playlist already loaded since I can assign its Id to the action (b), but I can not simply get the handle list of the drag n drop action without sending it to a playlist (a).
a) My workflow is: drop -> handle list -> get paths of tracks -> save paths into .m3u8 file
b) For a playlist already loaded: drop -> playlist -> autosave paths to linked .m3u8 playlist file
Answering to myself some time later... it's possible to get the handle list without sending it to any playlist, as long as the tracks are dragged from foobar2000 and are selected on the active playlist. It will cancel the drop action after doing something with the selected tracks and cancel it when the files are from outside (obviously it can be improved using 'on enter', instead of only 'on move', etc.)
// Drag n drop to copy/move tracks to playlists (only files from foobar)
addEventListener('on_drag_over', (action, x, y, mask) => {
// Avoid things outside foobar
if (action.Effect === dropEffect.none || (action.Effect & dropEffect.link) === dropEffect.link) {action.Effect = dropEffect.none; return;}
// Set effects
if (mask === dropMask.ctrl) {action.Effect = dropEffect.copy;} // Mask is mouse + key
else {action.Effect = dropEffect.move;}
on_mouse_move(x, y, mask);
});
addEventListener('on_drag_drop', (action, x, y, mask) => {
// Avoid things outside foobar
if (action.Effect === dropEffect.none || (action.Effect & dropEffect.link) === dropEffect.link) {action.Effect = dropEffect.none; return;}
if (plman.ActivePlaylist !== -1) {
const selItems = plman.GetPlaylistSelectedItems(plman.ActivePlaylist);
const bSucess = doSomething(selItems);
if (bSucess) {
// Remove track on move
if (mask !== MK_CONTROL) {plman.RemovePlaylistSelection(plman.ActivePlaylist);}
}
}
action.Effect = dropEffect.none; // Forces not sending things to a playlist
});