# Perspective Text Field Numeric Keypad

**URL:** <https://forum.inductiveautomation.com/t/perspective-text-field-numeric-keypad/71229>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [March 17, 2023, 1:59pm UTC](https://forum.inductiveautomation.com/t/perspective-text-field-numeric-keypad/71229 "2023-03-17T13:59:21Z")\
**Posts on this page:** 1\
**Showing post:** 34

<div class="post-metadata">

**Author:** ![jimschaefer](https://avatars.discourse-cdn.com/v4/letter/j/c6cbf5/32.png) [@jimschaefer](https://forum.inductiveautomation.com/u/jimschaefer)\
**Post date:** [June 6, 2023, 12:59pm UTC](https://forum.inductiveautomation.com/t/perspective-text-field-numeric-keypad/71229/34 "2023-06-06T12:59:17Z")

</div>

After more work with this control I found a couple of significant areas for improvement.

First, I noticed that if you click on a number button then follow it by pressing the enter key it will repeat the last number. I was expecting that the enter key would post the message with the final value and close the form. This is a major shortcoming in my mind. I tried to fix this but found that the mouse click and enter generate the same onClick event and I could not find a way to distinguish betweeen the two. (see this post [Button events - how to tell difference between mouse click and pressing enter](https://forum.inductiveautomation.com/t/button-events-how-to-tell-difference-between-mouse-click-and-pressing-enter/74607)). I'd really love to see a solution for this !

Second, I used the keypad popup on a numeric control in a template (using the VIsion terminology) that I repeated several times on another screen. Whenever I entered data into one numeric field it updated all the instances on the page !

The solution I devised was to create a unique id for each instance of the template by using the time the popup was opened (thanks to a suggestion I found on another post).

- I added a custom property called "ownerID" to the numeric control
- I modified the numeric control "onMouseDown" event to use the system.date.time.now() in milliseconds as a unique ID (this should be unique since there is usually only one mouse click at a time on a page):

```auto
	popupOpenedTime = str(system.date.toMillis(system.date.now()))
	self.custom.ownerID = popupOpenedTime
	owner = self.custom.ownerID
	popParams = {'owner': owner, 'min': self.props.inputBounds.minimum, 'max': self.props.inputBounds.maximum, 'oldValue': self.props.value, 'units': self.custom.keypad.units}	
	posit = None if self.custom.keypad.centerScreen else {'left': event.clientX, 'top': event.clientY}	
	system.perspective.openPopup('keypadPopup-' + owner, 'Exchange/Keypad/Numeric Popup', title=self.custom.keypad.title, params=popParams, position=posit, showCloseIcon=True, draggable=True, resizable=True, viewportBound=True, modal=True, overlayDismiss=True)
	

```

- I modified the "keypadReturn" message handler on the numeric control to reference the "ownerID" now used in the payload

```auto
def onMessageReceived(self, payload):
	owner = self.custom.ownerID
	if owner == payload['owner']:

```

---

_[View the full topic](https://forum.inductiveautomation.com/t/perspective-text-field-numeric-keypad/71229)._
