Hi @WLewe,
Fortunately, you have the source code available for the Buttons in the framework. The class from which "normal" buttons (tigger on release) inherit is called Abstract Button. As you can see from the source code, it triggers on release.
#include <touchgfx/widgets/AbstractButton.hpp>
namespace touchgfx
{
void AbstractButton::handleClickEvent(const ClickEvent& event)
{
bool wasPressed = pressed;
pressed = (event.getType() == ClickEvent::PRESSED);
if ((pressed && !wasPressed) || (!pressed && wasPressed))
{
// Pressed state changed, so invalidate
invalidate();
}
if (wasPressed && (event.getType() == ClickEvent::RELEASED) && action)
{
// This is a click. Fire callback.
if (action->isValid())
{
action->execute(*this);
}
}
}
} //namespace touchgfx
You can create your own Button base class that does something else. In a way, you could say that AbstractButton could be called TriggerOnReleasedButton, or something like that.
Here's some pseudocode for your new TriggerOnPressedButton base class.
#include <gui/common/TriggerOnPressedButton.hpp>
void TriggerOnPressedButton::handleClickEvent(const ClickEvent& event)
{
...
if ( (event.getType() == ClickEvent::PRESSED) && action)
{
// ButtonPress. Fire callback.
if (action->isValid())
{
action->execute(*this);
}
}
...
}