2019-01-14 05:56 AM
Hello
I have a custom container common to several screen (with OK button in it).
How can i call a callback of the current screen when a button is pressed in the container ?
I do call the callback of the custom containe, but don't know how to propagate it to the current view.
(for example when OK button is pressed i want to execute the action in each view containing this custom container)
I there an example of this ?
thanks
regards
Solved! Go to Solution.
2019-08-05 05:50 AM
Hi @VKyri,
Back from vacation here. Did you remember to update your handler to take a box with border?
/Martin
2019-08-05 05:59 AM
Hello,
thank you for your reply. I think we can close this topic, as i found a solution for it...
Best regards
2019-08-05 06:05 AM
My new problem is to draw a circle on each touch screen press (at the position of the press) and on each screen drawn in touchGFX project... if you have any simple idea...
I tried to add an invisible box on all the screen to detect the press, but now the button behind this box are not activated by touchGFX...
thanks best regards
2019-08-05 06:13 AM
You could simply overwrite View::handleClickEvent(ClickEvent& evt); and do something at the pressed coordinates.
2019-08-05 06:23 AM
thank for the tip, but how can i implement this ?
Should i use the virtual void handleClickEvent(const ClickEvent& evt); from Screen.hpp ?
I tried in one of my screen code to add :
void DigicodeView::handleClickEvent(const ClickEvent& evt)
{
circle1.setPosition(0, 0, 144, 80);
}
but i have an error of compilation
Error[Pe298]: inherited member is not allowed ...
2019-08-05 06:31 AM
Yes, you should. Which line does it complain about?
Also, what you should do is statically allocate memory for a number of circles (in an array or list, etc) which are all hidden. You can then, on each press on the screen, place the next circle at the pressed x,y call mycircle.setvisible(true) and mycircle.invalidate(); until there are no more circles left.
/Martin
2019-08-05 06:35 AM
on the handleClickEvent i have the error
I just want a circle that will appear on the key press : so maybe it is not usefull the array ?
Thanks
2020-06-12 05:53 AM
This might be an old thread, but found it useful to share for future references.
Probably the easiest solution I found that defines a communication from the container "Child" back to the View "Parent" is:
void my_container::initialize()
{
my_container_local_flag = static_cast<FrontendApplication*>(Application::getInstance())->get_Model_flag_status();
}
2024-05-11 08:20 AM
Hello @Martin KJELDSEN
Thanks for your demo on this topic, it helps me a lot.
One more question: each time I click the box, it will call the callback twice(press and release the box).
Is there some way that I can listen to the release event only?
Thanks again!
Have a good day!
2024-05-11 09:25 AM
Finally, I got it.
Just checking the event type is enough:
void CustomContainer1::boxClickedHandler(const Box &box,
const ClickEvent &event) {
if (event.getType() != ClickEvent::RELEASED) {
return;
}
if (&box == &box2) {
touchgfx_printf("CustomCotainer: box clicked.\n");
if (viewCallback && viewCallback->isValid()) {
viewCallback->execute(type);
}
}
}