Universal Robots Forum

Reset textfield using multiple identicalprogramnodes

Hello all,

I would like to be able to use a programNode multiple times in my program tree. In this programnode there is a textfield that may be given a value each time.

Unfortunately, the value entered in the textfield is always passed to all programnodes.

I have the textfields set up this way
view

contribution

and I have already tried the following solutions in another topic ( Bug when trying to store string with # - #2 by hch ):

  • a white space before the hashtags
  • instead of #.# : &hashmark

I have also tried the following:

  • textfield.setText("");

But these syntaxes unfortunately do not work. So I already have a hunch that it’s because of the dataModel and that I need to reset it, but I don’t know how. Anyone who can tell me this or knows another solution?

Greetings Zoe

Are the actual values saved in the respective DataModels wrong or just the view is wrong?
Are you calling the view.set… functions in the OpenView of the contribution as well?
You should call the view.set… functions where you are setting the text of the textfields in the openView of the contribution.

That is indeed a good question
I have checked it and it is only the representation that is not correct, the value in the data model is correct.

it might be a stupid question, but how do I get this value into the OpenView without the “value” parameter?
And then how do I process it in the programView?

i have tried the following:

view:
textfield method:
instellenField.setText(setTextTextFieldStopVertraging.getText());

public void setTextTextFieldStopVertraging(String txt) {
TextTextFieldStopVertraging.setText(txt);
}

contribution
openview:
view.setTextTextFieldStopVertraging(INSTELLEN_STOPVERTRAGING);

But it didn’t work…

yours sincerely,

Zoë

In your view when you are creating the textfield you can leave it as you originally had it for setting the Initial value of “standaardInstellenFieldText” assuming that it is a String variable.
Also for setting the text you could do;

public void setInstellenField(Double value){
    instellenField.setText(String.valueOf(value));
}

The String.valueOf will take the Double value provided and turn it into a String.

As for the contribution; when you need data saved in the DataModel you should use the model.get() function to retrieve it like you do in “getInstellenField()” or you could just use that function you created.
For example in your case it would be

view.setTextTextFieldStopVertraging(getInstellenField());
//or
//view.setTextTextFieldStopVertraging(model.get(INSTELLEN_STARTVERTRAGING, DEFAULT_STARTVERTRAGING));

Thank you for your quick reply and the example
I have tried both solutions, but unfortunately it doesn’t seem to help… Every new programNode still shows the same value in the textfields. Also if I adjust them

Are there any other ways to solve this?

Sincerely,
Zoë

If you downloaded the Starter pack you can compare your setup to one of the URCap examples provided by UR. For Example the HelloWorldSwing shows an example of what you are doing, although they are using a String but it functions the same way. I would compare the two to see what may be wrong. They also use the UndoRedoManager, which I would also recommend using when setting your datamodel.

I believe you can also find these examples on Github.