2025-06-12 8:06 AM
Hi,
I have a custom board and im keen to get my design to be able to have buttons that trigger events when the user releases (onRelease) the button, as well as onPress.
Is this possible and how would i go about achiving it ?
Im using TouchGFX 4.20
2025-06-12 9:48 AM
Hello,
Try:
void CustomButton::handleClickEvent(const ClickEvent& event) {
if (event.getType() == ClickEvent::PRESSED) {
// Code to execute when the button is pressed
} else if (event.getType() == ClickEvent::RELEASED) {
// Code to execute when the button is released
}
}
2025-06-12 10:33 AM
thanks i've implemented this and created a new myButton and then tied the button to a test icon.
void HomeView::onMyButtonPressed(const CustomButton& btn)
{
// <-- Your PRESS logic here -->
test_icon.setVisible(false); // Ensure the button is visible when released
test_icon.invalidate(); // Redraw the button to reflect the change
// e.g. start an animation, change a bitmap, etc.
}
void HomeView::onMyButtonReleased(const CustomButton& btn)
{
// <-- Your RELEASE logic here -->
test_icon.setVisible(true); // Ensure the button is visible when released
test_icon.invalidate(); // Redraw the button to reflect the change
// e.g. navigate to another screen, trigger an action, etc.
}
however, what happens is the the test_icon flashes reasonably quickly even though my finger is held down on the new button. So this seems to be triggering a Release even though its still a press.