# MouseDrag() while mouse button is pressed

**URL:** <https://forum.juce.com/t/mousedrag-while-mouse-button-is-pressed/8597>\
**Category:** General JUCE discussion\
**Created:** [April 29, 2012, 10:28am UTC](https://forum.juce.com/t/mousedrag-while-mouse-button-is-pressed/8597 "2012-04-29T10:28:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![true-grue](https://avatars.discourse-cdn.com/v4/letter/t/4491bb/32.png) [@true-grue](https://forum.juce.com/u/true-grue)\
**Post date:** [April 29, 2012, 10:28am UTC](https://forum.juce.com/t/mousedrag-while-mouse-button-is-pressed/8597/1 "2012-04-29T10:28:27Z")

</div>

Hi all!

Is there a way to get a notification when the mouse moves over my component while a mouse button was originally pressed in some other component (i.e. dragged) ? I want to switch the state of some components just by dragging the mouse over them.

Thanks.

---

<div class="post-metadata">

**Author:** ![daven](https://avatars.discourse-cdn.com/v4/letter/d/59ef9b/32.png) [@daven](https://forum.juce.com/u/daven)\
**Post date:** [April 29, 2012, 4:44pm UTC](https://forum.juce.com/t/mousedrag-while-mouse-button-is-pressed/8597/2 "2012-04-29T16:44:56Z")

</div>

You could make the drag-to component a mouse listener of your dragged-from component.

---

<div class="post-metadata">

**Author:** ![true-grue](https://avatars.discourse-cdn.com/v4/letter/t/4491bb/32.png) [@true-grue](https://forum.juce.com/u/true-grue)\
**Post date:** [April 29, 2012, 6:10pm UTC](https://forum.juce.com/t/mousedrag-while-mouse-button-is-pressed/8597/3 "2012-04-29T18:10:55Z")

</div>

I’ll try it out, thank you!
