# Numeric stepper in perspective

**URL:** <https://forum.inductiveautomation.com/t/numeric-stepper-in-perspective/91466>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [June 6, 2024, 9:21am UTC](https://forum.inductiveautomation.com/t/numeric-stepper-in-perspective/91466 "2024-06-06T09:21:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [June 6, 2024, 9:21am UTC](https://forum.inductiveautomation.com/t/numeric-stepper-in-perspective/91466/1 "2024-06-06T09:21:42Z")

</div>

Hello!

I´m trying to replicate a numeric control with stepper up and down  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/3/43db91fce16349715d632e490a6cae3e2b7919fa.png)

To do so I added a NumericEntryField and 2 buttons on the side. All inside of a container.

In the container I created a custom property:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/c/1cef74ed12ca6867bd505dae53800a8d57579da9.png)

wich I bind from the NumericEntry Field  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/c/8cff64ca9506beb202d60819220e7b37129e7bfa.png)

and in the decrease buttons I added a script event onclick

def runAction(self, event):

```python
def runAction(self, event):
  currentValue = parent.custom.currentValue
    if currentValue > 0: 
        parent.custom.currentValue = currentValue - 1

```

and on the increase buttons I added a script event onclick

```python
def runAction(self, event):
    currentValue = self.view.parent.custom.currentValue
    self.view.parent.custom.currentValue = currentValue + 1

```

NOne of the versions, with  
parent.custom.  
or  
self.view.parent.custom

working  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/1/11cf3356fbde2065750ccbbc4701398e8f9382f9.png)

But I may missing something because is not working. Any ideas welcome.

---

<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:** [June 6, 2024, 9:27am UTC](https://forum.inductiveautomation.com/t/numeric-stepper-in-perspective/91466/2 "2024-06-06T09:27:48Z")

</div>

Is your NumericEntryField binding bidirectional?

You can simplify your code:

```python
def runAction(self, event):
    if parent.custom.currentValue > 0: 
        parent.custom.currentValue -= 1

```

Tip: as mentioned before, show the window title on your binding screenshots so we can see what exactly you are binding.

Also, the indentation is not correct on the first runAction script.

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [June 6, 2024, 9:31am UTC](https://forum.inductiveautomation.com/t/numeric-stepper-in-perspective/91466/3 "2024-06-06T09:31:45Z")

</div>

Thanks! still not working

> [@Transistor](#):
>
> ```python
> if currentValue > 0: 
> parent.custom.currentValue -= 1
> 
> ```

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/4/54024bb398e10801b27316a23e895afcc91f35b2.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/3/8380b2dcbdc54963fd4ee57004b2505453fe3266.png)

in:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/2/d2c66ec4061b278d97c80a62844a2b6cde200cae.png)  
we have this custom property  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/3/13f5c520f49248232f9d46404b0cba9ae44077f6.png)

---

<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:** [June 6, 2024, 9:32am UTC](https://forum.inductiveautomation.com/t/numeric-stepper-in-perspective/91466/4 "2024-06-06T09:32:52Z")

</div>

Sorry, error in my code. It should be,  
`if parent.custom.currentValue > 0:`  
Fixed.

I can't see any errors in your configuration.

Tips:

- Always use **onActionPerformed** rather than onClick. onClick will execute even if the button is disabled. onActionPerformed doesn't.
- Don't give your user options that won't work. On Button\_1's `props.enabled` create an expression binding,  
`parent.custom.currentValue > 0`  
Now you don't need the `if parent.custom.currentValue > 0:` in your event script.
- Do something similar with the Button\_0.
- Make sure that the button style changes when not enabled.

---

<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:** [June 6, 2024, 9:43am UTC](https://forum.inductiveautomation.com/t/numeric-stepper-in-perspective/91466/5 "2024-06-06T09:43:43Z")

</div>

I think the problem is you have left out `self`.

```python
def runAction(self, event):
	self.parent.custom.currentValue -= 1

```

Use the Browse Properties button in the script editor to avoid this kind of error.

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [June 6, 2024, 9:50am UTC](https://forum.inductiveautomation.com/t/numeric-stepper-in-perspective/91466/6 "2024-06-06T09:50:06Z")

</div>

Ok, great, working!

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/1/31c75d0ce5768436f1953c186f3b71da1a5bba38.png)

this was my problem. Thank you!
