s00500 / ESPUI

A simple web user interface library for ESP32 and ESP8266
https://valencia.lbsfilm.at/midterm-presentation/
Other
919 stars 173 forks source link

How to use a “Options” drop-down list outside of a tab-menu #214

Closed AWSW-de closed 10 months ago

AWSW-de commented 1 year ago

First of all: A big thanks for this well done interface!

I am currently working on a new 3D printable WordClock project and started to use your interface, because it saves me tons of time. Before I wrote an html configuration page manually and after some time while adding more and more functions it was not good to manage…

This is more a question than a bug, but with the given examples I could not figure out how to use a “Options” drop-down list outside of a tab-menu. I want to add a drop down list to select the language of the WordClock layout and interface as well. The values are stored in a int variable as “0” for German and f.e. “1” for English language….

Can you please add an example how to add such an options menu to achieve this ?

Thanks in advance! =)

thomastech commented 1 year ago

I use ControlType::Option extensively in my project. You can review the related ESPUI code at https://github.com/thomastech/PixelRadio See files named /src/webGUI.cpp and /src/callBacks.cpp

TL;DR: Since you want your menu choices to handle int values, your callback code would convert EPSUI's sender->value string vars to your required int vars. That's all there is to this.

AWSW-de commented 1 year ago

Thanks a lot! I will have a look at this. Thanks for the hint as well. Kind regards

AWSW-de commented 1 year ago

Hello, sorry i need to come back to this topic. Had a deep look into the linked files and they all use the tab option too...

Can you give me short example of an option list without the tab usage?

Thanks in advance :)

Kind regards

cormalenv commented 10 months ago

For those that come across this question and to close it off...

In ESPUIO.cpp, the basic control functions such as ESPUI.button() or ESPUI.slider()), ESPUI.text() are built on the more complex "addControl" with "Control::noParent" for the "parentalControl" (eg tab) variable.

You can therefore use "Control::noParent" for the "tab" variable in the constructor of the Select control type eg

ESPUI.addControl( ControlType::Select, "Title", "Default Option", ControlColor::Dark,Control::noParent,selectCallback);

AWSW-de commented 10 months ago

Thanks for the hint. I will try that soon. =)

AWSW-de commented 10 months ago

For those that come across this question and to close it off...

In ESPUIO.cpp, the basic control functions such as ESPUI.button() or ESPUI.slider()), ESPUI.text() are built on the more complex "addControl" with "Control::noParent" for the "parentalControl" (eg tab) variable.

You can therefore use "Control::noParent" for the "tab" variable in the constructor of the Select control type eg

ESPUI.addControl( ControlType::Select, "Title", "Default Option", ControlColor::Dark,Control::noParent,selectCallback);

Works fine, thanks a lot :)

AWSW-de commented 10 months ago

Closed