Changing Button Image

  1. 4 years ago

    ingurgite

    22 Oct 2019 User since 2018

    Hi,

    I would like to programmatically change the image of a button when it is pressed. For an image, I can change its value through var.image = image.

    For a button, it seems that there is a notion of state. I've tried all the types of states and could not succeed. Also, it seems that there is no method to retrieve the current state of a button?

    Thanks.

  2. andrea

    23 Oct 2019 Administrator User since 2016

    Hi @ingurgite,
    you can programmatically change the image of a button for a specific state, for example:
    ```
    Button1.setImageForState(image1, ControlState.Normal)
    Button1.setImageForState(image2, ControlState.Highlighted)
    ```

    In this way, the `image1` is presented when the button is in the normal state and the `image2` is presented when the button is pressed.

  3. ingurgite

    26 Oct 2019 User since 2018

    Thanks @andrea. I had tried that but it seems I had made a mistake.

    Thanks a lot.

or Sign Up to reply!