cancel
Showing results for 
Search instead for 
Did you mean: 

TouchGFX IconButtonStyle::getCurrentlyDisplayedIcon() is const buggy

maciek
Associate II

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);
    }

2 REPLIES 2
Osman SOYKURT
ST Employee

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

Osman SOYKURT
ST Software Developer | TouchGFX
maciek
Associate II

Glad to hear. Thank you.