Skip to main content
GMeur
Associate III
May 22, 2019
Solved

setAction with an additional parameter

  • May 22, 2019
  • 1 reply
  • 774 views

Hi,

When using the 'setAction' function of the class Button, why can't I pass a callback object taking one more parameter than just the "const touchgfx::AbstractButtonContainer&"?

Here's my CallBack object with its corresponding handler function:

Callback<NumpadBis, const touchgfx::AbstractButtonContainer&, const int> _keyPressed;
void keyPressedHandler(const touchgfx::AbstractButtonContainer& src, const int);

And this doesn't work:

aKey->setAction(_keyPressed);

While it works just fine if I remove the "int" param.

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

Because the internals of the Button execute the callback with just one parameter - The handler and Callback object must match. You can just do your own implementation of a button that defines a different callback, executes the callback internally with your additional parameters - Allowing you to specify a matching handler that takes multiple arguments.

/Martin

1 reply

Martin KJELDSEN
Martin KJELDSENBest answer
Principal III
May 23, 2019

Because the internals of the Button execute the callback with just one parameter - The handler and Callback object must match. You can just do your own implementation of a button that defines a different callback, executes the callback internally with your additional parameters - Allowing you to specify a matching handler that takes multiple arguments.

/Martin