2023-02-03 07:07 AM
Hello,
Is there any workaround to the following problem- I am trying to get a icon's bitmap number from the src pointer in buttonPressedCallbackHandler after pressing the flexbutton which consists of IconButtonStyle. So I am doing following simple casting to have access to the method getCurrentlyDisplayedIcon:
void settingsScreenView::buttonPressedCallbackHandler(const touchgfx::AbstractButtonContainer& src)
{
TextButtonStyle< IconButtonStyle< ImageButtonStyle< ClickButtonTrigger > > >* cc = (TextButtonStyle< IconButtonStyle< ImageButtonStyle< ClickButtonTrigger > > >*) &src;
}
But when I try calling the method:
cc->getCurrentlyDisplayedIcon();
I get the "passing X as 'this' argument discards qualifiers [-fpermissive]" error in getCurrentlyDisplayedIcon method. The problem is that the getCurrentlyDisplayedIcon method is constructed like this:
Bitmap getCurrentlyDisplayedIcon() const
{
return (T::getPressed() ? iconPressed : iconReleased);
}
And T::getPressed IS NOT a const method. This couses the error during compilation. Adding const to the getPressed method or simply changing it to AbstractButtonContainer::pressed makes it working.
What bothers me most- in ImageButtonStyle.hpp there is similar method which is written properly:
Bitmap getCurrentlyDisplayedBitmap() const
{
return (AbstractButtonContainer::pressed ? down : up);
}
2023-02-07 01:18 AM
Hello maciek,
Thank you for your comment, you have indeed pointed a bug. Our team has been informed about it, and we'll patch it for a future version. I'll get back to you when I'll have more info concerning this issue.
/Osman
2023-02-07 02:58 AM
Glad to hear. Thank you.