Safely delete a drag & drop component

im trying to figure out a way to safely delete a new component i put in a DragAndDropContainer after its mouse up. however, the DragAndDropContainer recives a mouseUp() call only after the “parent” component which initiated the drag function. and this only allows me to delete the component before it is being dropped.

any simple way to overcome this?

You might need to explain that again for me… you mean that you’ve added a comp to a draganddropcontainer, then dragged that new comp, and want to delete it after the drag has finished?

yes. with the following order
– make new component (just for the dragging stage)
– add to draganddropcontainer
– drag it.
– drop it. (or not)
– delete it

or i can also use this alternative:
– make new component (just for the dragging stage)
– add to draganddropcontainer
– drag it.
– drop it. (or not)
– if its not dropped in its destined target - delete it

i kinda solved it with an AsyncUpdater triggered from the mouse up
im not 100% sure if thats the correct way to do it, but this way it deletes the component only after the ItemDropped() method is being called. is there a more elegant way to do this?

An Asyncupdater is certainly a good way to do that.

(Or even just “delete this” in the mouse-up… the code should be robust enough to handle that!)

mouseUp() gets called before ItemDropped(), which causes the component to be deleted before it can be used. thats why i used the AsyncUpdater, which as i understand waits for all gui handling methods to finish before it runs… am i correct?

Ah, I see. Yes, an asyncupdater is the right thing to use then. It won’t get called at least until the current event callback has finished, which will work fine in this case.