[Logo] TCC discussion forum
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Top Downloads] Top Downloads   [Groups] Back to home page 
[Register] Register /  [Login] Login 

Multiline Text Dialog menu RSS feed
Forum Index » tcMenu Arduinio library
Author Message
k


Joined: Jun 17, 2021
Messages: 18
Offline
Hello,
Recently found this library, and so far it is really helpful.


I currently have a BaseDialog which is presented with ( dlg->show ) & a second line text is presented with dlg->copyIntoBuffer, It works, but text formatting doesnt.

I want to use multiline dialog but trying \n does not seem to work ( I also tried to using dlg->copyIntoBuffer again but it just uses the text in the last one.).
How can I achieve multiline text in the dialog ?


I am using an ESP32 and st7735 LCD

Any help is appreciated
Thank you
davetcc


Joined: Jan 19, 2019
Messages: 492
Offline
Hi there, as you're on ESP32 you'll be using the MenuBasedDialog. With menu-based dialog, you can add extra menu items to it very easily. The easiest way to do this would be to add an extra menu item to your dialog to take the extra data. Any menu item can be created at runtime, and the menu item type documentation shows you how to create each type of item and runtime.

Each menu item type page describes how to create items at runtime: https://www.thecoderscorner.com/products/arduino-libraries/tc-menu/menu-item-types/

There's documenation around BaseDialog and MenuBasedDialog here: https://www.thecoderscorner.com/ref-docs/tcmenu/html/_base_dialog_8h.html

And here's a place that we add such an extra menu item to the dialog in the code: https://github.com/davetcc/tcMenuLib/blob/d1c070d5d983aa1cc91e09dd06c890e63ff6e8bb/src/graphics/DialogRuntimeEditor.cpp#L49, we don't have an example with an additional menuitem being created in a dialog, we'll look to fix that with the next release.

EDIT There's also a section on base dialog here: https://www.thecoderscorner.com/products/arduino-libraries/tc-menu/rendering-with-tcmenu-lcd-tft-oled/
k


Joined: Jun 17, 2021
Messages: 18
Offline
Thank You!

But I only need to add more text not menu items. Is there a way to just add more lines of text?
davetcc


Joined: Jan 19, 2019
Messages: 492
Offline
Not at the moment, a current limitation is that menu-items have to fit on one line, unless they are lists which work like a submenu, so you would probably need to create an extra TextMenuItem and insert it into the dialog. The summary is that to keep the performance drag of calculating items as low as possible the height is calculated upfront. So if you need two lines (or even more than that), just add suitable extra menu-items to the dialog. Menu Items are very lightweight, so it should not make a noticeable difference to your application.

https://www.thecoderscorner.com/ref-docs/tcmenu/html/class_text_menu_item.html

and

https://www.thecoderscorner.com/products/arduino-libraries/tc-menu/menu-item-types/editabletext-menu-item/ (EDIT correct URL)

Also, copy into buffer must only be called after show(), otherwise, it takes no effect.

You can format any menu item using the theme API discussed in the documentation, this allows various justification, formatting, spacing, and fonts, but not multi-line.

You could put in a feature request on the tcMenuLib for allowing multiline formatting, but it would need a lot of thought in how it was handled, and if I'm honest, we probably don't have the capacity to add it in the near future.
davetcc


Joined: Jan 19, 2019
Messages: 492
Offline
I'll look to add this case of adding extra menu-items into one of the examples.
k


Joined: Jun 17, 2021
Messages: 18
Offline
Thank you very much!
davetcc


Joined: Jan 19, 2019
Messages: 492
Offline
Although it's on a branch in the middle of development, there's a new example that you could look at:

https://github.com/davetcc/tcMenuLib/blob/remote-refactor-feature/examples/dynamicMenuItems/dynamicMenuItems.ino
 
Forum Index » tcMenu Arduinio library
Go to:   
Mobile view
Powered by JForum 2.7.0 © 2020 JForum Team • Maintained by Andowson Chang and Ulf Dittmer

This site uses cookies to analyse traffic, serve ads by Google AdSense (non-personalized in EEA/UK), and to record consent. We also embed Twitter, Youtube and Disqus content on some pages, these companies have their own privacy policies.

Our privacy policy applies to all pages on our site

Should you need further guidance on how to proceed: External link for information about cookie management.