I want to add a box dynamically on a button click in the buttoncallbackhandler() function.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-04 4:33 AM
So I tried creating a box in the buttoncallback function as follows :
touchgfx::Box * box_temp = new touchgfx::Box();
box_temp->setPosition(170,180,500,220);
box_temp->setColor(touchgfx::Color::getColorFrom24BitRGB(255,255,255));
box_temp->setVisible(true);
add(*box_temp);
box_temp->invalidate();
but on pressing the button the app freezes.
When tried to debug on trying to allocate memory using new the control reaches on
hardfault_handler(){}
Any suggestions?
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
‎2020-11-08 9:54 PM
Hello,
TouchGFX is allocating statically memory so you should avoid trying to create widgets dynamically.
One solution would be to create your box already in the Designer and then make it appear only at the right moment using setVisible(true). This way you ensure that the memory is correctly allocated for your Box and as long as the Box is not visible TouchGFX does not care about it (so it does not render it).
When your question is answered, please close this topic by choosing Select as Best.
/Alexandre
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-08 9:54 PM
Hello,
TouchGFX is allocating statically memory so you should avoid trying to create widgets dynamically.
One solution would be to create your box already in the Designer and then make it appear only at the right moment using setVisible(true). This way you ensure that the memory is correctly allocated for your Box and as long as the Box is not visible TouchGFX does not care about it (so it does not render it).
When your question is answered, please close this topic by choosing Select as Best.
/Alexandre
