Skip to main content
kjtl
Associate
September 27, 2019
Solved

Classes/functions to change the button graphics?

  • September 27, 2019
  • 2 replies
  • 876 views

Hi, 

I'm trying to change the button bitmap from "button_pressed.png" to "button.png", after an interrupt event (without touching the display) . Could anyone shed some light on where I can swap the graphics? I'm a CPP novice, so the more information you can provide the better. 

many thanks, 

K

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

Hi @kjtl​,

Use this function

 /**
 * @fn virtual void Button::setBitmaps(const Bitmap& bmpReleased, const Bitmap& bmpPressed);
 *
 * @brief Sets the bitmaps used by this button.
 *
 * Sets the bitmaps used by this button.
 *
 * @param bmpReleased Bitmap to use when button is released.
 * @param bmpPressed Bitmap to use when button is pressed.
 */
 virtual void setBitmaps(const Bitmap& bmpReleased, const Bitmap& bmpPressed);

So, essentially you could:

myButton.setBitmaps(Bitmap(BITMAP_NEW_BUTTON_RELEASED_ID, Bitmap(BITMAP_NEW_BUTTON_PRESSED));
myButton.invalidate();

2 replies

Martin KJELDSEN
Martin KJELDSENBest answer
Principal III
September 27, 2019

Hi @kjtl​,

Use this function

 /**
 * @fn virtual void Button::setBitmaps(const Bitmap& bmpReleased, const Bitmap& bmpPressed);
 *
 * @brief Sets the bitmaps used by this button.
 *
 * Sets the bitmaps used by this button.
 *
 * @param bmpReleased Bitmap to use when button is released.
 * @param bmpPressed Bitmap to use when button is pressed.
 */
 virtual void setBitmaps(const Bitmap& bmpReleased, const Bitmap& bmpPressed);

So, essentially you could:

myButton.setBitmaps(Bitmap(BITMAP_NEW_BUTTON_RELEASED_ID, Bitmap(BITMAP_NEW_BUTTON_PRESSED));
myButton.invalidate();

kjtl
kjtlAuthor
Associate
September 30, 2019

That is just what I needed, thank you!