Go Down

Topic: Nextion, changing text on other page. (Read 310 times) previous topic - next topic


Feb 25, 2019, 08:55 pm Last Edit: Feb 25, 2019, 08:56 pm by StevenBoon
One more Nextion question:
I have an interface where you can enter a code. If the code is 5411, the Arduino code finds this to be true and sets a button text to "Complete!"

The code:
Code: [Select]

NexButton Matrix = NexButton(1, 2, "b23");          //on page 1
NexButton MSubmit = NexButton(4, 1, "b12");      //on page 4
NexText MHeader = NexText(4, 15, "t1");              //on page 4

void MSubmitPopCallback(void *ptr) {
  if(matrixcode == "5411") {
  matrixcode = "";

All the playing to enter the code is on page 4, and MHeader.txt is working correctly.
The problem is that Matrix.txt doesn't change.

I have been playing and figured that if I make it:
Code: [Select]

NexButton Matrix = NexButton(1, 2, "b2");          //on page 1

the "b2" on page 4 is changed to "Complete!" instead of the b2 on page 1!
So apparently the Nextion doesn't write cross-page.

Does anyone know a solution?


Arduino and website programmer


Well sir, please enlighten me on the correct coding! :)


Two things:

The component on the inactive page that you want to change must be vscope global.

When referencing the component you need to say which page it is on (the library is a bit weak in this regard), so either declare the component with the page prefix: NexText t0 = NexText(1, 1, "page1.t0"), or go lower level and write the command manually: sendCommand("page1.t0.txt="cheese").

Go Up