How to listen for tracklist selection changes?

To discuss development of addons / skins / customization of MediaMonkey.

Moderators: jiri, drakinite, Addon Administrators

DaledeSilva
Posts: 906
Joined: Sun May 28, 2006 4:22 am
Location: Australia
Contact:

How to listen for tracklist selection changes?

Post by DaledeSilva »

Hi, I'm trying to listen for any change the user makes to their selection in either the now playing list or the main tracklist, but I'm having trouble.

From this forum post I figured out that I can use app.listen like this...

Code: Select all

app.listen( uitools.getSelectedTracklist(), 'change', ()=>{
        console.log("selection changed (from uitools)");
});
But I find that it fires whenever I change the selection in either the now playing list or main list (good so far), but only until I change nodes. Then it just stops.

Am I doing something wrong? Is there a better way to achieve this?
Product Designer & Indie Developer.
Building at the intersection of motion, art, and code.
Find me on twitter and all the other ones here.
Ludek
Posts: 5021
Joined: Fri Mar 09, 2007 9:00 am

Re: How to listen for tracklist selection changes?

Post by Ludek »

Hmm, then I guess that
app.listen(document.body, 'viewchange', () => { });
should work to get the new selected tracklist?

Code: Select all

let _selectedTracklist = uitools.getSelectedTracklist();
let _selectedTracklistEvt = app.listen( _selectedTracklist , 'change', ()=>{
       	console.log("tracklist selection changed");
});

app.listen(document.body, 'viewchange', () => { 
	app.unlisten(_selectedTracklist, 'change',  _selectedTracklistEvt);
	 _selectedTracklist = uitools.getSelectedTracklist();
	_selectedTracklistEvt = app.listen( _selectedTracklist , 'change', ()=>{
        	console.log("tracklist selection changed");
	});
});
Post Reply