Add text dynamically in Container/ScrollList
Hi, i'm kinda new to TouchGFX and i'm trying to programmatically add text inside a container of mine that i created to use as template in a ScrollList, but I was unsuccessful.
The idea is: For each text added, an item appears in ScrollList WITH the text
I have a textArea in touch designer with wildcard buffer
That's what im trying to do in code. At the moment, the list items appeared, but no text. Most of the code was created by ChatGPT as long as i don't know how to proceed

view.cpp
#include <gui/usb_teste_screen/usb_testeView.hpp>
usb_testeView::usb_testeView() {}
void usb_testeView::setupScreen()
{
usb_testeViewBase::setupScreen();
addItem("Test1");
addItem("Test2");
addItem("Test3");
}
void usb_testeView::tearDownScreen()
{
usb_testeViewBase::tearDownScreen();
}
void usb_testeView::addItem(const char* text)
{
int numItems = scrollList2.getNumberOfItems();
scrollList2.setNumberOfItems(numItems + 1);
scrollList2.invalidate();
}
void usb_testeView::updateItem(UsbContainer& item, int16_t itemIndex)
{
// Convert text to Unicode::UnicodeChar
Unicode::UnicodeChar textBuffer[256];
Unicode::strncpy(textBuffer, "Teste", 256);
textBuffer[256] = '\0';
item.setText(textBuffer);
}
view.hpp
#ifndef USB_TESTE_VIEW_HPP
#define USB_TESTE_VIEW_HPP
#include <gui_generated/usb_teste_screen/usb_testeViewBase.hpp>
#include <gui/usb_teste_screen/usb_testePresenter.hpp>
class usb_testeView : public usb_testeViewBase
{
public:
usb_testeView();
virtual ~usb_testeView() {}
virtual void setupScreen();
virtual void tearDownScreen();
void addItem(const char* text);
void scrollWheel1UpdateItem(UsbContainer& item, int16_t itemIndex);
void updateItem(UsbContainer& item, int16_t itemIndex);
};
#endif // USB_TESTE_VIEW_HPP
container.cpp
#include <gui/containers/UsbContainer.hpp>
#include <string.h>
#include <touchgfx/Unicode.hpp>
UsbContainer::UsbContainer()
{
}
void UsbContainer::setText(const touchgfx::Unicode::UnicodeChar* text)
{
touchgfx::Unicode::strncpy(textArea1Buffer, text, TEXTAREA1_SIZE - 1);
textArea1Buffer[TEXTAREA1_SIZE - 1] = '\0';
textArea1.setWildcard(textArea1Buffer);
textArea1.invalidate();
}container.hpp
#ifndef USBCONTAINER_HPP
#define USBCONTAINER_HPP
#include <gui_generated/containers/UsbContainerBase.hpp>
#include <touchgfx/Unicode.hpp>
class UsbContainer : public UsbContainerBase
{
public:
UsbContainer();
virtual ~UsbContainer() {}
void setText(const char* text);
void setText(const touchgfx::Unicode::UnicodeChar* text);
};
#endif // USBCONTAINER_HPP