Jog Button on Touchscreen HMI in Perspective

Hi everyone,

I have a jog button on a touch screen HMI that is hosting my perspective session. The goal is that when I hold the button down, the machine will jog until I release the button. With the help of a past forum post I was able to get it working while using a mouse. The logic is as follows:

onMouseDown:

def runAction(self,event):
	self.custom.clickReleased = False

	def confirm_if_click_held():
		from time import sleep 
		sleep(0.5)
		if not self.custom.clickReleased:	
			self.custom.tag=True
	system.util.invokeAsynchronous(confirm_if_click_held)

onMouseLeave AND onMouseUp:

def runAction(self,event):
	self.custom.clickReleased = True
	self.custom.tag = False

However, I need this to apply when using only the touchscreen, as there won't be a mouse in the field. With the logic as is, using the touchscreen when I press the button down, nothing happens until I release it, and then the machine begins to move. It isn't until I press somewhere else on the screen to act as the 'mouse release,' that the movement stops. I have tried putting this logic on other mouse events, on the component event 'onActionPerformed', and even on a text label in case the physical pressing was throwing it off. Please let me know if there is a work around to this issue or if it is even possible to achieve this goal. Thank you!

1 Like

Jogging and momentary buttons in general on web based HMI are consider a bad thing. Related:

3 Likes

To add to Transistor's post

As noted, the answer is to not have a jog button. Or not use Perspective.

1 Like

In the case of this being a non-safety issue, the application currently is super small scale and not doing anything crazy. We do plan on implementing the continuous stream of timestamps so the PLC would catch it. Right now, it just seems like the button extension functions do not work correctly with a touch screen. I do not see anything in the HMI settings regarding 'clicking' either.

My guess is that the touchscreen is registering long presses as right clicks. You might have to check your touchscreen driver settings to see how it's set to react to long presses. I typically just use start/stop buttons instead of buttons that need held (unless I'm using physical buttons on a panel, in which case I will allow jogging by holding a button).

2 Likes

This makes sense, previously when holding down on the button it would highlight the text and give copy/paste/etc options, until I disabled this using a stylesheet.css function. In this case then, I do not see a onRightClick or similar option under mouse events, does anyone know if there is some action to capture a right click?

Also to preface, the OS of the HMI is Linux. I checked the configuration settings and did not see any settings related to this issue.

You cannot do that in Perspective without writing a custom java module that implements a new Perspective button type. Because any other solution uses scripts that run in the gateway, not in the browser. If it was easy, or even just moderately difficult, it would have been done by now.

Some future developer will copy your questionable code and use it for something more significant. I strong recommend you not do this.

Relevant recent topic:

4 Likes

If I tried to do

def runAction(self,event):
	self.custom.clickReleased = False

	def confirm_if_click_held():
		from time import sleep 
		sleep(0.5)
		if not self.custom.clickReleased:	
			system.tag.writeBlocking(['lastConfirmedRunRequest', system.date.addSeconds(system.date.now(),1)]
	system.util.invokeAsynchronous(confirm_if_click_held)

and comms broke, what would happen, that script would keep running until comms resumed and detected the click was off?

1 Like

But where did comms break?