The original question has been improved (which is appreciated) to include the IDE which the poster is using. In this stackexchange.com space we primarily concern our selves with answering questions about developing using the Arduino IDE. While the Nextion Editor looks interesting, some may consider it off topic.
For those who come here interested in controlling the brightness of their Nextion Display and are using the Arduino IDE, there is this answer:
There appears to be several Nextion Arduino Library efforts to choose from. If you are using this Nextion Display Library, here is the example code which set the screen brightness. The part of the code which sets the screen brightness is rather simple and resides in the Arduino loop() function. In the loop() function the brightness is set repeatedly as the program continues to run:
void loop() {
int brightness = analogRead(A0);
int bright = map(brightness, 0, 1024, 0, 100);
String dim = "dim=" + String(bright);
myNextion.sendCommand(dim.c_str());
}
For those of you using the Nextion editor and the Nextion Arduino Libraries, there is this github.com Issue which talks about adding multiple missing Nextion features including a screen brightness function. This issues appears to still be OPEN (Bad support? / Bad house-keeping?). But is over a year old so may have be incorporated. If so, here is the example code from that link:
/**
* Set the brightness of the display.
*
* @param buffer - number (0 - 100).
*/
bool setBrightness(byte buffer);