cancel
Showing results for 
Search instead for 
Did you mean: 

How can I get trigers button click and button unclick?

Ayagb.2239
Associate II

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

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
HPham.1590
Senior

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
				}
		}
}

View solution in original post

7 REPLIES 7
Alexandre RENOUX
Principal

Hello,

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

/Alexandre

HPham.1590
Senior

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

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

Thank you…. Code Worked fine….

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

Hieu

PCu1
Senior
Ayagb.2239
Associate II

Thank you Pierre,

I will try it.

Ahmet.