Register /
Login
|
Desktop view
|
tcMenu Arduinio library
»
Multiline Text Dialog menu
Author:
k
17/06/2021 07:06:39
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
Author:
davetcc
17/06/2021 07:52:47
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/
Author:
k
17/06/2021 08:45:11
Thank You!
But I only need to add more text not menu items. Is there a way to just add more lines of text?
Author:
davetcc
17/06/2021 09:56:06
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.
Author:
davetcc
17/06/2021 10:08:45
I'll look to add this case of adding extra menu-items into one of the examples.
Author:
k
17/06/2021 11:14:36
Thank you very much!
Author:
davetcc
17/06/2021 17:49:50
Register /
Login
|
Desktop view
|