Skip to main content
maciek
Associate III
February 3, 2023
Question

TouchGFX IconButtonStyle::getCurrentlyDisplayedIcon() is const buggy

  • February 3, 2023
  • 2 replies
  • 1465 views

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

This topic has been closed for replies.

2 replies

Osman SOYKURT
Technical Moderator
February 7, 2023

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 SOYKURTST Software Developer | TouchGFX
maciek
maciekAuthor
Associate III
February 7, 2023

Glad to hear. Thank you.