# \[IMPLEMENTED\] Alternative input (virtual keyboard) for text field

**URL:** <https://forum.universal-robots.com/t/implemented-alternative-input-virtual-keyboard-for-text-field/406>\
**Category:** Product Wishlist\
**Created:** [December 14, 2016, 5:18pm UTC](https://forum.universal-robots.com/t/implemented-alternative-input-virtual-keyboard-for-text-field/406 "2016-12-14T17:18:25Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon87661449](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@anon87661449](https://forum.universal-robots.com/u/anon87661449)\
**Post date:** [December 14, 2016, 5:18pm UTC](https://forum.universal-robots.com/t/implemented-alternative-input-virtual-keyboard-for-text-field/406/1 "2016-12-14T17:18:25Z")

</div>

Is it possible to switch the virtual keyboard used for input text in a text field in my URCap?

The keyboard which is used is not good when I want to edit some existing text. It is not possible to move the caret, it always overwrites all existing (which can be annoying, if you have a longer text).  
A keyboard which does this better is the one, which is used when changing a feature name.

If not possible, I would place this as a feature request. _[EDIT: moved to feature requests]_

Btw: in Polyscope are too many different virtual keyboards, this could be made a bit more consistent.

---

<div class="post-metadata">

**Author:** ![anon87661449](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@anon87661449](https://forum.universal-robots.com/u/anon87661449)\
**Post date:** [December 16, 2016, 8:14pm UTC](https://forum.universal-robots.com/t/implemented-alternative-input-virtual-keyboard-for-text-field/406/2 "2016-12-16T20:14:24Z")

</div>

The keyboard for the numerical input provides the possibility to set the caret (and also to mark portions to delete/overwrite). I wish this could be possible with the text keyboard.  
 ![](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/1X/647dd90e3171bb785c439e95a8ee2f1c4022808d.png)

---

<div class="post-metadata">

**Author:** ![artiminds](https://avatars.discourse-cdn.com/v4/letter/a/df788c/32.png) [@artiminds](https://forum.universal-robots.com/u/artiminds)\
**Post date:** [December 20, 2016, 8:38am UTC](https://forum.universal-robots.com/t/implemented-alternative-input-virtual-keyboard-for-text-field/406/3 "2016-12-20T08:38:34Z")

</div>

I’d like to second this request. We have an extension where the user has to enter an expression (text). Not being able to easily edit the expression is a no-go for our customer.

---

<div class="post-metadata">

**Author:** ![anon87661449](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@anon87661449](https://forum.universal-robots.com/u/anon87661449)\
**Post date:** [January 12, 2017, 10:09pm UTC](https://forum.universal-robots.com/t/implemented-alternative-input-virtual-keyboard-for-text-field/406/4 "2017-01-12T22:09:10Z")

</div>

no one else who is annoyed by the current behaviour?  
@jbm: any comment from UR? Shouldn’t be too hard to implement (since such a keyboard already exists (edit feature name)). Also, wouldn’t impact current URcaps.

---

<div class="post-metadata">

**Author:** ![jbm](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/jbm/32/614_2.png) [@jbm](https://forum.universal-robots.com/u/jbm)\
**Post date:** [January 13, 2017, 11:16am UTC](https://forum.universal-robots.com/t/implemented-alternative-input-virtual-keyboard-for-text-field/406/5 "2017-01-13T11:16:25Z")

</div>

@anon87661449

I reckon I will need a bit more elaboration on the use case for above.  
“Annoying” obviously counts, however would make sense to build a bit more around it.

Currently you select the keyboard type in HTML, by either “number” or “text”.  
However would it also make sense to toggle e.g. the “Expression Editor”, and what would the use case be?

---

<div class="post-metadata">

**Author:** ![anon87661449](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@anon87661449](https://forum.universal-robots.com/u/anon87661449)\
**Post date:** [January 13, 2017, 11:44pm UTC](https://forum.universal-robots.com/t/implemented-alternative-input-virtual-keyboard-for-text-field/406/6 "2017-01-13T23:44:06Z")

</div>

@jbm Ok, the use case is that the user needs to change the text that he previously typed (e.g. correcting a typo or adjust the value of just one character (e.g. a state number)):  
 ![](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/1X/f70e23da84fd437e10ed6d5bb8a137991f9921ed.png)  
This is an example for sending commands to an external HMI (where the string is quite large (\> 20 chars)).

Or, imagine, we have a lot of similar instances (of this URcap), where only a little portion of the text differs, so the user uses copy-paste and wants to change the new ones a little bit.  
In the current situation, he needs to type it every time all over again.

If you were the user and I (as the provider of this URcap) tell you, that you cannot correct/change portions of the text, but instead you have to remember the (complete) previous text and type it all over again, how would you deal with this?

Try to change only one character of a feature name, that’s easily doable, right? -\> Polyscope already has such a keyboard (and a change wouldn’t impact existing URcaps).

Please no advice, how to implement this in another way in the URcap (e.g. reducing the text), since this is just a constructed example, it’s all about editing existing / previously entered text.

@artiminds or anyone else, do you have further (detailed) arguments?

---

<div class="post-metadata">

**Author:** ![jbm](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/jbm/32/614_2.png) [@jbm](https://forum.universal-robots.com/u/jbm)\
**Post date:** [January 18, 2017, 10:21am UTC](https://forum.universal-robots.com/t/implemented-alternative-input-virtual-keyboard-for-text-field/406/7 "2017-01-18T10:21:45Z")

</div>

Thanks, @anon87661449  
This use-case is great, I will move on with a feature request in this respect.

---

<div class="post-metadata">

**Author:** ![mbush](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/mbush/32/76_2.png) [@mbush](https://forum.universal-robots.com/u/mbush)\
**Post date:** [March 1, 2017, 10:31am UTC](https://forum.universal-robots.com/t/implemented-alternative-input-virtual-keyboard-for-text-field/406/8 "2017-03-01T10:31:57Z")

</div>

There are spots within the current Polyscope where we have the same issue, I believe for instance popups and the user assignment screen where once you have entered the text that you want the user to see you cannot edit it (with the built-in keyboard, have to use an external keyboard). Annoying is not even the right word for it., especially when you cannot even see all of what you typed on the same screen and you now have to retype all of it to fix a single typo.

 ![](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/1X/647d12ef02f87863fa8f17c8c0d0ac2f4bc7a2a3.gif)

---

<div class="post-metadata">

**Author:** ![anon87661449](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@anon87661449](https://forum.universal-robots.com/u/anon87661449)\
**Post date:** [March 15, 2017, 8:44pm UTC](https://forum.universal-robots.com/t/implemented-alternative-input-virtual-keyboard-for-text-field/406/9 "2017-03-15T20:44:09Z")

</div>

request implemented in PolyScope 3.4

---

<div class="post-metadata">

**Author:** ![anon61537835](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@anon61537835](https://forum.universal-robots.com/u/anon61537835)\
**Post date:** [April 19, 2022, 1:08pm UTC](https://forum.universal-robots.com/t/implemented-alternative-input-virtual-keyboard-for-text-field/406/10 "2022-04-19T13:08:08Z")

</div>

I have been looking for a tutorial or example on how to implement the numerical keyboard, as i am pretty new to UR.  
any suggestions ?

---

<div class="post-metadata">

**Author:** ![eric.feldmann](https://avatars.discourse-cdn.com/v4/letter/e/94ad74/32.png) [@eric.feldmann](https://forum.universal-robots.com/u/eric.feldmann)\
**Post date:** [April 19, 2022, 1:39pm UTC](https://forum.universal-robots.com/t/implemented-alternative-input-virtual-keyboard-for-text-field/406/11 "2022-04-19T13:39:56Z")

</div>

[https://plus.universal-robots.com/urcap-basics/api-reference-docs/](https://plus.universal-robots.com/urcap-basics/api-reference-docs/)

Quick link to the API guide.

In your Contribution’s constructor, it can be helpful to assign an instance of the UserInteraction interface like so:

```auto
userInteraction = apiProvider.getUserInterfaceAPI().getUserInteraction();

```

Here’s an example of the code used in the Contribution to create an Integer keyboard, complete with a Validator that will restrict user input to be between whatever is passed as the minValue and maxValue.

```auto
public KeyboardNumberInput<Integer> getIntegerKeyoard(Integer initialValue, Integer minValue, Integer maxValue) {
		KeyboardInputFactory keyboardFactory = userInteraction.getKeyboardInputFactory();
		InputValidationFactory validationFactory = userInteraction.getInputValidationFactory();
		
		InputValidator<Integer> validator = validationFactory.createIntegerRangeValidator(minValue, maxValue);
		
		final KeyboardNumberInput<Integer> keyboardInput = keyboardFactory.createIntegerKeypadInput();
		keyboardInput.setErrorValidator(validator);
		keyboardInput.setInitialValue(initialValue);
		
		return keyboardInput;
	}

```

This example is written to take 3 arguments: a value that will appear by default in the field when clicked (almost always just pulling the .getText() of the object) , a minimum value, and a maximum value.

This is called from the View by putting the following inside whatever onClick listener you’ve chosen:

```auto
final KeyboardNumberInput<Integer> keyboardInput = provider.get().getIntegerKeyoard(
	    Integer.valueOf(myTextField.getText()), 
	    (int)minValue, 
	    (int)maxValue);
	keyboardInput.show(myTextField, provider.get().getCallbackForMyTextField());

```

Then finally you also need to include a Callback method in your contribution that overrides the “on ok” method so you can capture the user pressing the OK button:

```auto
	@Override
	public KeyboardInputCallback<Integer> getCallbackForMyTextField() {
		return new KeyboardInputCallback<Integer>() {

			@Override
			public void onOk(final Integer value) {
				onMyTextFieldValueChanged(value);
			}
		};
	}

```

Then you can do whatever you want to do in the “onMyTextFieldValueChanged()” method. You could also just put it in the onOK method if you wanted, but I like to break things up for clarity. Typically this is where you’d do some model.set() calls to store whatever the user has typed to the model.
