# onMouseUp event does not fire if mouse is dragged after clicking down

**URL:** <https://forum.inductiveautomation.com/t/onmouseup-event-does-not-fire-if-mouse-is-dragged-after-clicking-down/46458>\
**Category:** Ignition\
**Created:** [May 6, 2021, 9:53pm UTC](https://forum.inductiveautomation.com/t/onmouseup-event-does-not-fire-if-mouse-is-dragged-after-clicking-down/46458 "2021-05-06T21:53:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nick.christensen1](https://avatars.discourse-cdn.com/v4/letter/n/bcef8e/32.png) [@nick.christensen1](https://forum.inductiveautomation.com/u/nick.christensen1)\
**Post date:** [May 6, 2021, 9:53pm UTC](https://forum.inductiveautomation.com/t/onmouseup-event-does-not-fire-if-mouse-is-dragged-after-clicking-down/46458/1 "2021-05-06T21:53:34Z")

</div>

I have a button that is intended to write a tag to True while being held down, and then write it back to False when let go. To achieve this, intuition would suggest using the onMouseDown event to write the True value, and then onMouseUp to write the False value.

If the button is clicked without moving the mouse at all this works as expected. If you press the mouse click down, then move the mouse, and then let go the onMouseDown event will fire but onMouseUp will not. This applies whether you actually move the mouse off the button while clicked down or leave it in the bounds IF you have an image on the button, which I do. If you don’t have an image on the button it does still fire the onMouseUp event as long as you don’t move the mouse out of the bounds of the button.

Any suggestions or workarounds? Maybe a way to disable click and drag entirely?

---

<div class="post-metadata">

**Author:** ![matthew.ayre](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matthew.ayre/32/19499_2.png) [@matthew.ayre](https://forum.inductiveautomation.com/u/matthew.ayre)\
**Post date:** [May 7, 2021, 10:43am UTC](https://forum.inductiveautomation.com/t/onmouseup-event-does-not-fire-if-mouse-is-dragged-after-clicking-down/46458/2 "2021-05-07T10:43:10Z")

</div>

> [@nick.christensen1](#):
>
> If you press the mouse click down, then move the mouse, and then let go the onMouseDown event will fire but onMouseUp will not.

This is expected behaviour. This allows the user to not perform the action if they pressed it by mistake (for the mouse up not triggering).

> [@nick.christensen1](#):
>
> leave it in the bounds IF you have an image on the button

This is a bit weird, and I guess it has something to do with how Ignition embeds images into buttons?

Before going any further with this, have a good read of this thread: [Very Concerning Read/Write Issues. Important information for all users](http://forum.inductiveautomation.com/t/very-concerning-read-write-issues-important-information-for-all-users/18583)

Implementing momentary presses can be hazardous depending on how they're used.

---

<div class="post-metadata">

**Author:** ![nick.christensen1](https://avatars.discourse-cdn.com/v4/letter/n/bcef8e/32.png) [@nick.christensen1](https://forum.inductiveautomation.com/u/nick.christensen1)\
**Post date:** [May 26, 2021, 1:39pm UTC](https://forum.inductiveautomation.com/t/onmouseup-event-does-not-fire-if-mouse-is-dragged-after-clicking-down/46458/3 "2021-05-26T13:39:41Z")

</div>

Follow up on this, if you use the onMouseOut() event instead of the onMouseLeave() event the image related failure case does not occur.
