Deleting the selected item in a listbox

list.removeItemAt () <-- how can I set this parameter so that it only deletes the selected item? I understand that I can place an integer (say 4) there, but then it only deletes whatever is in place 4. What if the 3rd place were highlighted?

Is there a way that I can modify this script so that the parameter slot will understand that it is supposed to delete place 3 (or 2 or 12)?

I really appreciate you reading this whole thing - thank you -

Sam

This is not difficult at all… just add the following code to your change handler (the name of my change handler is OnChange)


onChange=function(flistbox){
	flistbox.removeItemAt(flistbox.getselectedindex);
}

Hope that answers your question.

this worked (but only when we clicked the button, then selected the item):

onChange=function(flistbox){
flistbox.removeItemAt(flistbox.getselectedindex);
}

unfortunately, what we are trying to do is select the item, and then click the remove button -

I appreciate your time on this :-\ if you have any advice, I would be most grateful -

Thank you -

no problem… forget the OnChange event.

I named my listbox instance “mybox”

I created a button and attached the following code to the button:


on(release){
	
mybox.removeitemat(mybox.getselectedindex());
}


there you go…!

that really does work!

:rambo: