Skip to main content
maciek
Associate III
March 12, 2019
Solved

Triggering ClickEvent for more than one widget

  • March 12, 2019
  • 5 replies
  • 1929 views

Hello,

I am using slideMenu widget and it works fine. Now I am trying to open this widget by a gesture. Normally I would override gestureEventCallback in my View- and actually I did it but it does not work well. I have two slide menus on top and on the left and if I slide from the left to right at 30o angle I get 2 gestures- HORIZONTAL and VERTICAL, always in the same order therefore it is impossible for me to detect if I should open top or left menu.

I came to idea that I can first check the click event for pressed, save the coordinates, wait for gesture event and then wait for released click event- in that combination I am able to get all data to find out if I should open top or left menu. But If I override click event in my view I can not trigger buttons which are present in the view.

So my question is- is it possible to, after I trigger view's clickEventHandler pass the event further to trigger next widget in the area where the click occured? Is TouchGFX capable of doing that?

This topic has been closed for replies.
Best answer by Martin KJELDSEN

You can also just forward it application-wide by calling Application::handleClickEvent(evt);

/Martin

5 replies

Martin KJELDSEN
Principal III
March 12, 2019

Hi @maciek​,

Simply forward the event to any widget using widget.handleClickEvent(evt); //evt gotten from your views handleClickEvent();

/Martin

maciek
maciekAuthor
Associate III
March 12, 2019

Yea but let's assume I don't know what widgets are on the position where the event occured. Solution with calling handleClickEvent assumes I know what widget I should trigger. I would like to pass it further without concerning about x/y.

I did it manually- I know that there can be only 1 container that's children can be triggered:

Drawable* widget = containerMain.getFirstChild();
while (widget != 0)
{
	Rect rect;
	rect = widget->getAbsoluteRect();
	if (evt.getX() > rect.x && evt.getX() < rect.x + rect.width
			&& evt.getY() > rect.y && evt.getY() < rect.y+ rect.height
			&& widget->isTouchable())
	{
		widget->handleClickEvent(evt);
	}
	widget = widget->getNextSibling();
}

Martin KJELDSEN
Martin KJELDSENBest answer
Principal III
March 13, 2019

You can also just forward it application-wide by calling Application::handleClickEvent(evt);

/Martin

JHarding
Senior
March 3, 2021

Im not sure if the source code has just changed since this post was initially made, but the only way I could call the handleClickEvent(evt) on the application was like this:

Application::getInstance()->handleClickEvent(evt);

Zbobo.1
Associate III
March 17, 2021

Hi @JHarding​ ,

I wonder how to define evt in my class.