Problem on DrawableButton click?


#1

When I try to trigger an action on a click on a DrawableButton, buttonClicked gets never called (I have ImageButtons triggering correctly the buttonClicked method in the same class). I tried both setClickingTogglesState (false) and setClickingTogglesState (true).

Am I doing something wrong ? Here is the code:

        playButton = new DrawableButton("PlayButton",DrawableButton::ImageFitted);

        addAndMakeVisible(playButton);

        playButton->setImages(Drawable::createFromImageData(BinaryData::play_png, BinaryData::play_pngSize),nullptr,nullptr,nullptr,Drawable::createFromImageData(BinaryData::play_on_png, BinaryData::play_on_pngSize),nullptr,nullptr,nullptr);

        playButton->setClickingTogglesState (false);

        playButton->setColour(DrawableButton::backgroundOnColourId, Colour (0x00000000));

Thanks.


#2

If that snippet is complete, then the problem is probably the fact that you haven't added your listener to the button.


#3

You are right... duhh....