[Solved] Nextion - IT IS NOT POSSIBLE to use functions events from another page

Due to the fact that the Nextion IDE doesn't support functions or reusable code, you can place the code under a botton or hotspot's touch event and call it with the command click.

I read that you can call these function from another page, but no matter if I set the visibility of the variable or page to global, use the id or objectname - I always get the error message: Invalid Component ID.

So: is it possible and if so how?

Hello,

The Event code is never global.

I have already tried it, despite being a reference in the Nextion Editor Guide.

ID
Selecting ID to will toggle if the component .objnames are displayed in the upper left region of the component space. Yellow labelled components have a .vscope local, while black labelled components have a .vscope of global. (Hint: Event code is never global). When selecting multiple components, green labelled components indicate multiple components have been selected, while the one blue labelled component will be used as the baseline component. To change the baseline component while the group is still active selected, simply click on the already selected component you want to become the baseline component.

Nextion Editor Guide

-Thanasis Seitanis

Due to the fact that the Nextion IDE doesn't support functions or reusable code, you can place the code under a botton or hotspot's touch event and call it with the command click.

Not only not possible from another page note also that you need a click and an 'un-click'. A click alone will cause strange behaviour.

So, for example:

  Serial1.print(F("click b2,1"));
  Serial1.write(0xff);
  Serial1.write(0xff);
  Serial1.write(0xff);
  Serial1.print(F("click b2,0"));
  Serial1.write(0xff);
  Serial1.write(0xff);
  Serial1.write(0xff);

@Thanasis: Thanks for the explantion ... even if I would have wished for a different answer.

@Perry: Thanks for the hint. I'm sure it would have taken me a long time to figure it out.