Skip to main content
Ayagb.2239
Associate II
August 10, 2020
Solved

How can I get trigers button click and button unclick?

  • August 10, 2020
  • 7 replies
  • 1577 views

I want to use a button, than I need button click and unclick time execute virtual function. How can it?

Thanks.

This topic has been closed for replies.
Best answer by HPham.1590

I'm not really understand what's you want, but as my guest, I think you need to call function when the button Pressed and one again when Released.

You can refer this function, add to ScreenView.cpp. and dont forget to define it at header file.

Best Regard,

Hieu

void Screen1View::handleClickEvent(const ClickEvent& evt)
{
	if (your_object.getRect().intersect(Rect(evt.getX(), evt.getY(), 1, 1)))
		{
			if (evt.getType() == ClickEvent::PRESSED)
			{
				// Your code when Pressed
			}
			if (evt.getType() == ClickEvent::RELEASED)
				{
				// Your code when Released
				}
		}
}

7 replies

Alexandre RENOUX
Visitor II
August 11, 2020

Hello,

Can you reformulate your question and maybe elaborate ? I unfortunately don't understand your issue.

/Alexandre

HPham.1590
HPham.1590Best answer
Associate III
August 11, 2020

I'm not really understand what's you want, but as my guest, I think you need to call function when the button Pressed and one again when Released.

You can refer this function, add to ScreenView.cpp. and dont forget to define it at header file.

Best Regard,

Hieu

void Screen1View::handleClickEvent(const ClickEvent& evt)
{
	if (your_object.getRect().intersect(Rect(evt.getX(), evt.getY(), 1, 1)))
		{
			if (evt.getType() == ClickEvent::PRESSED)
			{
				// Your code when Pressed
			}
			if (evt.getType() == ClickEvent::RELEASED)
				{
				// Your code when Released
				}
		}
}

Ayagb.2239
Associate II
August 12, 2020

Thank you, HPham and Alexandre,

My question: I need to get signal when pressed a button and released button. This answer is ok for me.....

B.Regards.

Ahmet.

Ayagb.2239
Associate II
August 12, 2020

Thank you…. Code Worked fine….

HPham.1590
Associate III
August 12, 2020

you should set this question is answered, it'll help others person

Hieu

PCu1
Senior
August 13, 2020
Ayagb.2239
Associate II
August 14, 2020

Thank you Pierre,

I will try it.

Ahmet.