cancel
Showing results for 
Search instead for 
Did you mean: 

setAction with an additional parameter

GMeur
Senior

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Martin KJELDSEN
Chief III

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

View solution in original post

1 REPLY 1
Martin KJELDSEN
Chief III

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