How to listen for tracklist selection changes?

Post a reply

Smilies
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:

BBCode is ON
[img] is ON
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: How to listen for tracklist selection changes?

Re: How to listen for tracklist selection changes?

by Ludek » Wed Aug 16, 2023 8:20 am

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");
	});
});

How to listen for tracklist selection changes?

by DaledeSilva » Fri Jul 21, 2023 10:15 am

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?

Top