Start a new topic

text component refresh upon page change

hi to all:

I've serially communicated a text value into a text component on say page 0.  Then I switch to page 1, do some stuff, then when I switch back to page 0 the text components are blank.

Clues on how to refresh these components upon page entry would be appreciated  (I've tried component refresh, no avail).

Thanks, John.

You have to reload the page data each time a page changes. This is why I have implemented the page change event in my fork of the arduino code. This allows you to get a event wheN the page changes, which can call a function and allow you to push the new pages data to the display.

I thought of that for a solution but was hoping for something more elegant, ie internal to the nextion system.  Thanks for the tip anyway . . .

set the txt component as "vscope:global".

refer to this example:Advanced Application 2: Use Global and Variable to Transmit Values Among Pages

ok, thanks.  so that keeps the text stored on that page.  This is good to know as I can use it.

But I was looking for the text to be stored in a variable that each page displays, i.e., each page displays the same identical text.

2 people like this

It can be done within nextion (no need for Arduino or another MCU)

you have to:

- Set the components as "Global" (important)

- in the other page you write this syntax: pagename.componentvalue="..."

example: you need to set text value of text t1 in page A to "button pressed" when button b1 in page B is pressed

so you write in the events of button 1 of page B: A.t1.txt="button pressed"

Login or Signup to post a comment