cancel
Showing results for 
Search instead for 
Did you mean: 

Classes/functions to change the button graphics?

kjtl
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions
Martin KJELDSEN
Chief III

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

View solution in original post

2 REPLIES 2
Martin KJELDSEN
Chief III

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
Associate II

That is just what I needed, thank you!