2022-04-19 03:00 AM
I can use listLayout add() item and remove() item good, but I don't know
how to get selected item number on callBackHandler()?
Have any example for me to study ?
void Screen2View::callBackHandler(CustomContainer2 & cc_1)
{
listLayout1.remove(cc_1);
invalidate();
}
Thank you & Best regards,
Solved! Go to Solution.
2022-04-19 06:45 AM
Hello @YCF.1 ,
A good starting point is to analyze the ListLayout example in TouchGFXDesigner.
You will see in MainView.cpp that a callback "listElementClicked" is implemented. This method will be called every time the user clicks on the button "Delete" and provides the specific CustomListElement object that was clicked. That's already a good way to isolate each element of your list.
Then, if you want to get the specific index of the clicked element of your list, you can try that :
int itemIndex;
void setupListElement(const Bitmap& iconBMP, TEXTS iconTextID, int elementIndex);
void CustomListElement::setupListElement(const Bitmap& iconBMP, TEXTS iconTextID, int elementIndex)
{
itemIndex = elementIndex;
icon.setBitmap(iconBMP);
text.setTypedText(TypedText(iconTextID));
text.resizeToCurrentText();
invalidate();
}
listElements[0].setupListElement(Bitmap(BITMAP_ICON0_ID) , T_LIST_ELEMENT_00 , 0);
int item_nr = element.itemIndex; // "element" is a CustomListElement here
I will also join my project to this post, it might be easier for your understanding.
Let me know if that helped or if you have other questions,
/Yoann
2022-04-19 06:45 AM
Hello @YCF.1 ,
A good starting point is to analyze the ListLayout example in TouchGFXDesigner.
You will see in MainView.cpp that a callback "listElementClicked" is implemented. This method will be called every time the user clicks on the button "Delete" and provides the specific CustomListElement object that was clicked. That's already a good way to isolate each element of your list.
Then, if you want to get the specific index of the clicked element of your list, you can try that :
int itemIndex;
void setupListElement(const Bitmap& iconBMP, TEXTS iconTextID, int elementIndex);
void CustomListElement::setupListElement(const Bitmap& iconBMP, TEXTS iconTextID, int elementIndex)
{
itemIndex = elementIndex;
icon.setBitmap(iconBMP);
text.setTypedText(TypedText(iconTextID));
text.resizeToCurrentText();
invalidate();
}
listElements[0].setupListElement(Bitmap(BITMAP_ICON0_ID) , T_LIST_ELEMENT_00 , 0);
int item_nr = element.itemIndex; // "element" is a CustomListElement here
I will also join my project to this post, it might be easier for your understanding.
Let me know if that helped or if you have other questions,
/Yoann
2022-04-19 07:24 PM
2022-04-20 01:58 AM
Hi! Yoann KLEIN!
I retry again to create new List Layout on screen main page.
I click list's button but no callback to remove list layout item.
I check below file :
MainView.hpp / MainView.cpp
CustomListElement.hpp / CustomListElement.cpp
I don't know what is mistake on my code, can you help me.
Thank you & Best regards.