1

Topic: Edit Field

Dear all,

I hope someone will be able to help me.
I would like to know if it was possible to add a condition with the edit field when we press the button "Enter".
For example, I write 400 to the edit field, then the indicator change his value to 400, but only when a new value is entered. Here is an example of my Arduino code:

  nb_cycles_1= RemoteXY.nombre_cycle_1;
  itoa ( nb_cycles_1, RemoteXY.cycles_restants_1, 10);

It does it every time, i would get something like:

if (A new value is entered to the edit field nombre_cycle_1) then{
  nb_cycles_1= RemoteXY.nombre_cycle_1;
  itoa ( nb_cycles_1, RemoteXY.cycles_restants_1, 10);
}
I hope someone will be able to help me <3

Charlie.

2 (edited by Gunner 2021-07-03 05:22:01)

Re: Edit Field

Hello... first, can you edit your post and format code separately from comments.

Use the <> icon on the editor and paste your code in-between the two square bracketed labels

[ code ]
your code here
[ /code ]

Then can you explain a bit better your question... what do you mean by this?

to add a condition

And further clarification of this...

but only when a new value is entered

I think this is to be expected... unless you also have something else updating the indicator

"And voila, which is French for.......'and then I found out.'" - Ready Player One

3

Re: Edit Field

A good solution would be to check if the value in the input field has changed

if (RemoteXY.nombre_cycle_1 != nb_cycles_1) {  // value changed
  // you can check the range of the entered value
  if ((RemoteXY.nombre_cycle_1 < 10) || (RemoteXY.nombre_cycle_1 > 20)) {  // value out of range 10..20
    RemoteXY.nombre_cycle_1 = nb_cycles_1;   // return the previous value in the edit field
  }
  else {  // value in range
    nb_cycles_1 = RemoteXY.nombre_cycle_1;   // save value as previous 

    // some things if the edit field was changed

    itoa (nb_cycles_1, RemoteXY.cycles_restants_1, 10);
  }
}