# Button Long Click with 8.1.33

**URL:** <https://forum.inductiveautomation.com/t/button-long-click-with-8-1-33/81171>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [October 30, 2023, 3:58pm UTC](https://forum.inductiveautomation.com/t/button-long-click-with-8-1-33/81171 "2023-10-30T15:58:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chad\_Gregory](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/chad_gregory/32/51192_2.png) [@Chad\_Gregory](https://forum.inductiveautomation.com/u/Chad_Gregory)\
**Post date:** [October 30, 2023, 3:58pm UTC](https://forum.inductiveautomation.com/t/button-long-click-with-8-1-33/81171/1 "2023-10-30T15:58:59Z")

</div>

I originally wrote this code with 8.1.24, there has been a lot of stuff to happen so I'm not sure exactly what is causing my script to stop working correctly. Seems like there is a change in how Ignition handle mouseDown/mouseUp events. When I click and hold a button with this code, it automatically performs the \< 1s action instead of waiting for my finger to lift off the mouse button. (I am still holding down the button when the mouseUp event triggers.

Here is my onMouseDown event script:

```auto
def runAction(self, event):
	import time
	
	self.custom.mouseDown = time.time()

```

here is my onMouseUp script:

```auto
def runAction(self, event):
	import time
	import utils
	
	if (time.time() - self.custom.mouseDown) < 1:
		params = {
			'action': 'func',
			'stub': 'canPerformQCCheck',
			'func': 'requestQCCheck',
			'label': 'Request QC Check',
			'kwargs': {
				'line': self.view.params.line
			}
		}
		system.perspective.openPopup("badgeScanPopup", 'Components/Badge Scan', params)
	else:
		params = {
			'action': 'func',
			'stub': 'canPerformQCCheck',
			'func': 'clearQCCheck',
			'label': 'Clear QC Check',
			'kwargs': {
				'line': self.view.params.line
			}
		}
		system.perspective.openPopup("badgeScanPopup", 'Components/Badge Scan', params)

```

Anyone see a error in my script or is there something else going on?

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [October 30, 2023, 4:15pm UTC](https://forum.inductiveautomation.com/t/button-long-click-with-8-1-33/81171/2 "2023-10-30T16:15:44Z")

</div>

> [@Chad\_Gregory](#):
>
> ```auto
> import time
> import utils
> 	
> if (time.time() - self.custom.mouseDown) < 1:
> params = {
> 'action': 'func',
> 'stub': 'canPerformQCCheck',
> 'func': 'requestQCCheck',
> 'label': 'Request QC Check',
> 'kwargs': {
> 'line': self.view.params.line
> }
> }
> system.perspective.openPopup("badgeScanPopup", 'Components/Badge Scan', params)
> else:
> params = {
> 'action': 'func',
> 'stub': 'canPerformQCCheck',
> 'func': 'clearQCCheck',
> 'label': 'Clear QC Check',
> 'kwargs': {
> 'line': self.view.params.line
> }
> }
> system.perspective.openPopup("badgeScanPopup", 'Components/Badge Scan', params)
> 
> ```

I just tried this with code from the 8.1.34 Nightly build from last week and the Events worked exactly like I'd expect, where a "held" click executed your `else` block, and short clicks without any pause always executed the `if` block. Make sure you don't have any other events which interact with the `custom` prop in use here, and make sure your actual mouse is in working order.

Side note:  
What is `utils`? Is that a custom library? Invoking your script as-is resulted in an exception due to that import, and I was forced to remove it in order to verify your code.

---

<div class="post-metadata">

**Author:** ![Chad\_Gregory](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/chad_gregory/32/51192_2.png) [@Chad\_Gregory](https://forum.inductiveautomation.com/u/Chad_Gregory)\
**Post date:** [October 30, 2023, 5:17pm UTC](https://forum.inductiveautomation.com/t/button-long-click-with-8-1-33/81171/3 "2023-10-30T17:17:48Z")

</div>

Ahh the issue was I had touch simulation on in the browser. This project is going to run on a tablet so I running my browser in Responsive Design Mode.

> [@cmallonee](#):
>
> What is `utils`? Is that a custom library? Invoking your script as-is resulted in an exception due to that import, and I was forced to remove it in order to verify your code.

utils is a library script  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/6/563d82d27ab8293433e0c29b072fbfcdee3d69e1.png)
