# Perspective Button onClick Action scripting

**URL:** <https://forum.inductiveautomation.com/t/perspective-button-onclick-action-scripting/70493>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [March 1, 2023, 6:20pm UTC](https://forum.inductiveautomation.com/t/perspective-button-onclick-action-scripting/70493 "2023-03-01T18:20:31Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gerry\_Dion](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@Gerry\_Dion](https://forum.inductiveautomation.com/u/Gerry_Dion)\
**Post date:** [March 1, 2023, 6:20pm UTC](https://forum.inductiveautomation.com/t/perspective-button-onclick-action-scripting/70493/1 "2023-03-01T18:20:31Z")

</div>

Looking to get help scripting a momentary push button using the onClick action.

Very new to python. So far i've created a custom parameter at the root container level called: "start\_man" and using that in my onClick script.

How do I script "self.parent.custom.start\_man" to momentarily turn the boolean tag on which i've binded to "start\_man"

---

<div class="post-metadata">

**Author:** ![djs](https://avatars.discourse-cdn.com/v4/letter/d/e47774/32.png) [@djs](https://forum.inductiveautomation.com/u/djs)\
**Post date:** [March 3, 2023, 5:27pm UTC](https://forum.inductiveautomation.com/t/perspective-button-onclick-action-scripting/70493/2 "2023-03-03T17:27:46Z")

</div>

Momentary push buttons through HMIs are not recommended. This thread will lead to discussions about them:

> [@HMI Momentary button Gets stuck with N/O Bit of PLC](https://forum.inductiveautomation.com/t/hmi-momentary-button-gets-stuck-with-n-o-bit-of-plc/21388):
>
> [image] I have two dynamically tagged momentary button for each of this START and STOP bit. Some reason, most of the time, B10.0 get stuck and latched in PLC, this causes not able to shut the motor down. Its control value is assigned to its respective tag as bidirectional with 2.5 sec, but still it gets hung up. Any one experienced this type of problem or I am doing some thing wrong. ?

Or just all these threads (notice all the problems they tend to have):  
[https://forum.inductiveautomation.com/search?q=momentary%20push%20button](https://forum.inductiveautomation.com/search?q=momentary%20push%20button)

However, if you have to, you could use [system.tag.writeBlocking](https://docs.inductiveautomation.com/display/DOC81/system.tag.writeBlocking) in a Button's `onMouseDown` and `onMouseUp` events. I would personally not do it this way.

---

<div class="post-metadata">

**Author:** ![Roman\_Rozenshteyn](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@Roman\_Rozenshteyn](https://forum.inductiveautomation.com/u/Roman_Rozenshteyn)\
**Post date:** [March 22, 2024, 10:17pm UTC](https://forum.inductiveautomation.com/t/perspective-button-onclick-action-scripting/70493/3 "2024-03-22T22:17:57Z")

</div>

How would you do something like a jog command? The jog would only be active while the operator holds down the button.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [March 22, 2024, 10:30pm UTC](https://forum.inductiveautomation.com/t/perspective-button-onclick-action-scripting/70493/4 "2024-03-22T22:30:22Z")

</div>

> [@Roman\_Rozenshteyn](#):
>
> How would you do something like a jog command?

With a hard-wired button.  
Read post #2 and the linked articles carefully. The topic has been discussed many times on the forum.

---

<div class="post-metadata">

**Author:** ![Roman\_Rozenshteyn](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@Roman\_Rozenshteyn](https://forum.inductiveautomation.com/u/Roman_Rozenshteyn)\
**Post date:** [March 25, 2024, 6:44pm UTC](https://forum.inductiveautomation.com/t/perspective-button-onclick-action-scripting/70493/5 "2024-03-25T18:44:00Z")

</div>

I read through some of the posts, and it looks like this is an issue with the Vision button component. I'm working strictly with Perspective and, unless I'm missing something, I don't really see a way to make a momentary button.

I have three types of buttons in my project, buttons that write a value on action (set button), buttons that set a value and then reset it, and toggles.

The set and reset buttons are what I was referring to as momentary. The way I do these can vary but, for the most part are one of the following:

1. Set value onClick, reset value onMouseUp
2. Set value onActionPerformed, wait, reset value

Do you see any issues with my understanding of buttons?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 25, 2024, 6:48pm UTC](https://forum.inductiveautomation.com/t/perspective-button-onclick-action-scripting/70493/6 "2024-03-25T18:48:24Z")

</div>

> [@Roman\_Rozenshteyn](#):
>
> I read through some of the posts, and it looks like this is an issue with the Vision button component.

The discussions go back to the Vision-only days. The fundamental problems are not Vision-specific. And Vision has the tools (local code execution) with which to create robust work-arounds. (Not trivial, but possible.)

Perspective simply _ **cannot do this** _ reliably. The part that does the "reset value" cannot be guaranteed to happen on time, if at all. Do not try to Perspective perform two write operations, separated by time or user action, from one button. Full stop.

Hardly any UI on the market can do this truly reliably, but most are far more reliable than anything browser-based.

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [March 25, 2024, 7:01pm UTC](https://forum.inductiveautomation.com/t/perspective-button-onclick-action-scripting/70493/7 "2024-03-25T19:01:53Z")

</div>

FWIW, I've personally had issues with momentary buttons on several platforms, In touch, FactoryTrash, C-More (see less) and Vision. So it's not just an Ignition thing, it's a thing thing.

As far as jog buttons, unless the HMI/OIT is right next to the equipment, jog buttons are bad practice regardless. For maintenance jog they should be hardwired as previously suggested.

---

<div class="post-metadata">

**Author:** ![Roman\_Rozenshteyn](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@Roman\_Rozenshteyn](https://forum.inductiveautomation.com/u/Roman_Rozenshteyn)\
**Post date:** [March 25, 2024, 9:03pm UTC](https://forum.inductiveautomation.com/t/perspective-button-onclick-action-scripting/70493/8 "2024-03-25T21:03:57Z")

</div>

For majority cases I let the PLC reset the HMI bit but, this jog case is the one thing that bothers me. The motion controllers have their own IDE which has a jog button that seems to work without fail. I want to put similar functionality into the HMI, locked behind an elevated user, for troubleshooting purposes. I do have some hardwired controls that I can use if there is no other way.
