# Mouse Event after event component destruction

**URL:** <https://forum.juce.com/t/mouse-event-after-event-component-destruction/60453>\
**Category:** General JUCE discussion\
**Created:** [March 14, 2024, 5:58pm UTC](https://forum.juce.com/t/mouse-event-after-event-component-destruction/60453 "2024-03-14T17:58:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cool-mr-croc](https://avatars.discourse-cdn.com/v4/letter/c/958977/32.png) [@cool-mr-croc](https://forum.juce.com/u/cool-mr-croc)\
**Post date:** [March 14, 2024, 5:58pm UTC](https://forum.juce.com/t/mouse-event-after-event-component-destruction/60453/1 "2024-03-14T17:58:09Z")

</div>

Hello, imagine I have a component that I can drag on, I click and drag, I then delete the component as I’m dragging at some point, I drag some more, I unclick the mouse button that initiated the drag, I need to track each drag and when the mouse up event was fired. Is there a way I can do this? Can’t I hand over the mouse event from the original component to a new event component?

The event component in MouseEvent is const which denotes the inability to do this.

---

<div class="post-metadata">

**Author:** ![cool-mr-croc](https://avatars.discourse-cdn.com/v4/letter/c/958977/32.png) [@cool-mr-croc](https://forum.juce.com/u/cool-mr-croc)\
**Post date:** [March 14, 2024, 7:08pm UTC](https://forum.juce.com/t/mouse-event-after-event-component-destruction/60453/2 "2024-03-14T19:08:08Z")

</div>

The use case is I would like to drag on a tabbed components button, at times the bar itself, drag, and give the impression the entire thing is being dragged away into it’s own window, which I can do using a DocumentWindow. When I remove the active tab, the button is deleted. the solution I’m about to try is a simple engine edit (I hope) that doesn’t allow the owned array to delete the memory but release it instea,d I think hold onto it. It’s quite a specific solution to this use case and requires an engine edit so I’m looking for a more simple solution. If I could just hide a tab button, that would do it.

edit: I’ve found a less invasive way for my specific use case, I can set the tabbed button to be invisible, then move the rest to the left to hide the missing index, I’d still like to know if there is a better way to handle mouse events.
