cancel
Showing results for 
Search instead for 
Did you mean: 

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

Professional
Senior

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

25 REPLIES 25
Martin KJELDSEN
Chief III

Hi,

You need to add() the circle to the root container. Did you remember to do that? Just add all your circles in setupScreen() (even if they are invisible).

/Martin

Professional
Senior

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
Chief III

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
Chief III

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
Senior

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
Senior

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

Professional
Senior

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
Chief III

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
Chief III

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
Senior

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