2021-03-15 02:50 AM
I placed the buttons which are made with custom container in ScrollList.
I'd like to change screen by pressing each button.
How should I write my code for pressing button and change screen?
I uploaded the sample project. Please see the attached for your reference.
Thank you.
Solved! Go to Solution.
2021-03-22 02:08 AM
Hello MTana.1,
I made a simple code example to show you how to change screen when pressing a button in a ScrollList. Looking at the code should give you all the necessary answers.
There's several ways to implement what you want, but the enclosed solution is in my opinion the simplest.
Basically,
The main files to look at in the example are CustomContainer1.cpp/hpp and Screen1View.cpp/hpp
Hope this will help.
/Alexandre
2021-03-15 04:52 AM
Create interaction for change screen and assign it to dummy key.
Then in button call keyhandle.
static_cast<FrontendApplication*>(Application::getInstance())->handleKeyEvent(84);
2021-03-15 06:24 AM
Thank you for prompt answer.
I'd like to know how to get interaction from custom container of ScrollList items.
Sorry, I'm touchgfx beginner.
Thank you.
2021-03-17 04:17 AM
2021-03-17 11:46 AM
As first i mean you missuse list. Scrollist is designed to repeat one same custom container in many elements, Then i mean simply you use one button in custom container usw...
Second is each object have defined own callbacks methods, that you need implement. For example list have :
void Screen2View::scrollList1UpdateItem(MenuItem &item, int16_t itemIndex) {
if (itemIndex == cursorpos)
item.selit(1);
item.setLabel(touchgfx::TypedText(UI_Menu_Items_A[itemIndex]));
item.setIco(touchgfx::Bitmap(UI_Menu_Icons_A[itemIndex]));
}
and next is for example callbacks for screen/buuton touch/click where you call switch screen directly or as i describe on first reply.
Best method for beginer is learn from example codes.
2021-03-22 02:08 AM
Hello MTana.1,
I made a simple code example to show you how to change screen when pressing a button in a ScrollList. Looking at the code should give you all the necessary answers.
There's several ways to implement what you want, but the enclosed solution is in my opinion the simplest.
Basically,
The main files to look at in the example are CustomContainer1.cpp/hpp and Screen1View.cpp/hpp
Hope this will help.
/Alexandre
2021-03-22 03:29 PM
Thank you for your great help.
I understand your project. It's very simple and helpful.
I'll try on my project.
2021-03-22 06:04 PM
Hello MTana.1,
Perfect, if it works on your project, please close this topic by choosing Select as Best.
/Alexandre