How to change screen by pressing button in ScrollList.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-03-15 2: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.
- Labels:
-
TouchGFX
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-03-22 2: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,
- You create change screen interactions (done in Designer) in your custom Container used as a base for your ScrollList.
- You create an interaction (in Designer) that will trigger a virtual function when the button is clicked.
- You assign a number to each element of your ScrollList to differentiate them and call the right screen change accordingly.
The main files to look at in the example are CustomContainer1.cpp/hpp and Screen1View.cpp/hpp
Hope this will help.
/Alexandre
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-03-15 4: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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-03-15 6: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.​
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-03-17 4:17 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-03-22 2: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,
- You create change screen interactions (done in Designer) in your custom Container used as a base for your ScrollList.
- You create an interaction (in Designer) that will trigger a virtual function when the button is clicked.
- You assign a number to each element of your ScrollList to differentiate them and call the right screen change accordingly.
The main files to look at in the example are CustomContainer1.cpp/hpp and Screen1View.cpp/hpp
Hope this will help.
/Alexandre
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-03-22 3:29 PM
Thank you for your great help.
I understand your project. It's very simple and helpful.
I'll try on my project.​
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-03-22 6:04 PM
Hello MTana.1,
Perfect, if it works on your project, please close this topic by choosing Select as Best.
/Alexandre
