Start a new topic

Running global code/Best practice for PullDown menu

Hi all

My project contains a few pages with a menu bar on top (on every page), some of the buttons open a pulldown menu. That works fine but I have to place the pulldown on every page including code (it is a picture made visible or not and enabling/disabling touch areas). Is there an other concept doing this simpler?

2nd question is about running global code. I have some stuff relevant for multiple pages. Is it correct to put this code on a global page? Will this code executed if data is arriving from UART? (new values to show, page changes etc.) Or do I have to place this code on every page?




if things run well as expected, where is the need to do it different?

and no, there is no global code execution ... code is limited to your actual active page ...

Global code execution: 

If I had to make a change I have to do it on several pages, lot of redundant code


it runs as expected, but again it is difficult to maintain as you have all these pulldowns on top of all the other stuff in the editor. No problem if you have only one pulldown,but with a bunch it is quite difficult. My idea was that it is probably possible to define these pulldowns  once for multiple pages and make them visible on every page when needed.



redundant code

    - maybe time to rethink your overall projects workflow ...


    - many ways lead to Roma ...
    - every way has its specific advantages and disadvantages ...
    - there is no "Snake Oil" solution available ...
    - maybe good in implementation is bad in maintenance ...
    - maybe good in maintenance is slow in execution ...
    - maybe good in maintenance is bad in initial design ...
    - ...

Things you may think about ...

    - is there a real need for many separate pages ...
    - how many times will you update code after project finalizing that it will became a real issue ...
    - how many times will you update menues after project finalizing that it will became a real issue ...
    - not every academic issue is of relevance in real life ...



Your feedback does not really help me, anyway many thanks.

It is my first Nextion project and I'm looking for ways to improve the design. I'm looking for best practice from people who did probably the same with Nextion displays. I have years of experience in software engineering, but with Nextion i'm a real beginner.

I don't know what is your experience in engineering, for me your things to think about do not make sense, and it makes no sense to discuss "maybees" any further.

If anybody has good ideas how to deal with my topics with Nextion, feedbacks are very welcome.



sorry when my knowledge and experience won't fit your ideas ... that's also not my duty to prove ...

this is a public forum, so, just wait until maybe somebody else with more knowledge about Nextion HMI displays will answer ...

if you don't like to wait until maybe somebody answer in the way you desire, Itead also offers a payed enhanced support service ...



MCU side has ability for global

 - perhaps use MCU global function

Nextion does not have global execution other than

 - Instruction Set, System Variables

what size Nextion?


And what kind of parameters/constraints are you giving to a pull down menu?

Space occupied, number of menu items horizontal, number of submenus, submenu-items?

Hi Patrick

Attached a screenshot of one of my page. The menus do not have that much items, even no submenu items below an item. But I have 3 pulldown for now on one page. There is some logic to show and hide these menus, also code to deactivate/active hotspots. All these menus are pictures. The control logic is on the MCU what to do and what page to show. The code in the display is only that one related to show/hide graphics, save values for multiple pages and activate/deactivate hotspots. 


- choose bt_mode button will show submenu with three hotspots and enable these hotspots.

- when I click one hotspot submenu will hide and hotspots will be disabled

- display will send event of the hotspot to the MCU

- MCU will send display instructions what to do (e.g. switch to other page...)

I have multiple pages with the same top menu bar. I have to copy the entire code to every page. 





But Identical menus?  How many pages with the menu that needs copying?

The menu bt_Mode with the hotspots bt_Constant, bt_Pulse and bt_Battery is available on three pages. For bt_Settings there was also a similar submenu planned, but this will overload the editor workspace too much...

Attached screenshot from debugger...





Nextion Editor workspace won't overload

 - 250 components per page

 - bringing 3 or 4 from hidden to visible top a few ms - hardly noticeable.

Overload designer mentally keeping track of  multi layering. Yep.

But not too much of an issue for the firmware.

yes, sure. No problem from technical side. But the multi layering is not handy to use... It works fine, the question was if there is a way to make the same more celver, or if the way I made it is the only one. Especially the code needed has to be copied, so if I have to made a change I have to change the same on different pages.

The second question is related to the values you see. I have to made some simple math depending on the unit I set in Settings menu.


I will get the current always in mA from the MCU, but the user can choose the Unit in Settings menu to be mA or A. So I will do the formatting of the value in the display. I use this value in different pages. As far as I have understood I have to do the math on every page, there is no possibility to make the math somewhere and provide the values for all pages, correct?




Login or Signup to post a comment