Skip to main content
Professional
Associate III
August 5, 2019
Question

draw a circle during 100ms on each touch screen press with touchGFX

  • August 5, 2019
  • 25 replies
  • 4533 views

Hello,

Do you know if there is a simple way to make touchGFX draw a circle during a few ms on each touch screen press ?

best regards

This topic has been closed for replies.

25 replies

Professional
Associate III
August 6, 2019

Hi

thank you for the help;

Yes it works better with add function ! but now i am facing a new problem : my boxClickHandler is no more called

Now that the virtual handleClickEvent function is coded, how can we still receive event in all the callback of our widgets (box, images...) ?

Best regards

Martin KJELDSEN
Principal III
August 6, 2019

Simply forward the event to your widgets if you want only specific widgets to receive the event:

myWidget.handleClickEvent(evt);

And forward it locally to your entire view if you want every widget to receive it:

 View::handleClickEvent(evt);

/Martin

Martin KJELDSEN
Principal III
August 6, 2019

The more correct way to do this is to create a custom widget that registers for ticks. You can find many examples of this in the framework- Check the containers/SlideMenu.cpp or containers/SwipeContainer.cpp, for instance.

Application::getInstance()->registerTimerWidget(this);

In this way your widgets would be self aware of when to hide themselves, and you would not have to override the handleTickEvent() method to keep track of when to hide which circle. e.g. if the user touches two spots on the display in quick succession, you would have to manage ticks for each of those manually.

/Martin

Professional
Associate III
August 6, 2019

All my screens code is structured by using the setClickAction() function in the constructor of the screen :

   digicode_box_click0.setClickAction(BoxClickedCallback);

and in the callback i test each widget

void DigicodeView::digicode_boxClickHandler(const Box& b, const ClickEvent& evt)

{

   //Checking code

   //treat only pressed event

   if (evt.getType() != ClickEvent::PRESSED) return;

   if (&b == &digicode_box_click0)

   {

      updateEnteredCode(0);

   }

.....

Professional
Associate III
August 6, 2019

So i don't know how to call each widget with myWidget.handleClickEvent(evt);......

Professional
Associate III
August 6, 2019

Hello

thank you for your reply

i don't want the widget that are on the screen to be modify by the click event, i just want to know when a click is for them...

On the click event it is OK i can draw a circle, and on the tick event i can clear it, but i also want the callback of the widget to be called...

Best regards

Martin KJELDSEN
Principal III
August 6, 2019

I updated the post above related to forwarding:

If you want to forward locally to the entire view, call the following. This way you won't have to forward to each widget.

 View::handleClickEvent(evt);

/Martin

Martin KJELDSEN
Principal III
August 6, 2019

Okay, then you do not need to implement the handleClickEvent() method in your view. You could even have the circle be a part of your widget and have the widget display it depending on the coordinates pressed (your widget also implements handleClickEvent() )

Professional
Associate III
August 6, 2019

Thanks for the reply...

I don't understand you reply... but your code View::handleClickEvent(evt); seems to work fine : the event is well propagated for the boxes once treated byhandleClickEvent function (that draw the circle).

So i have to add the handleClickEvent function in all the screen view code ?

Best regards

Martin KJELDSEN
Principal III
August 6, 2019

My reply was on how to avoid having circles in the view itself, but inside a custom widget (since you're showing the circle at the exact spot you're clicking which is the widget that is already handling click events. But if you want to do the view approach - You do not need handleClickEvent() at all actually - You just need the callback handler to show one of the circles at the coordinates that were clicked - you can send these back in your callback.

/Martin