CCControlButton has a useless method called "setSelected" ???

CCControlButton has a useless method called "setSelected" ???
0.0 0


I want to ask a question, why method “isSelected” only works for CCMenuItem but CCControlButton use “isHighlighted” instead?

In the class of CCMenuItem,we can use “isSelected” method to detect whether the menu item is selected while the menu item pressed down.So, I think it is the same with the class of CCControllButton.
Then I use the “isSelected” method to detect the state of button.However, it doesn’t work. I look at the source code,find something different and strange.We can use “isHighlighted” method instead of.Because in the “CCControllButton::ccTouch~” methods it use “setHighlighted” method to mark the state of button whether is selected.
It looks well.However,the method “setSelected” became useless.What’s worst,it may be a bug!
On the other hand,it maybe the author left this method to us to use it manually.
At this point, I was lost in confusion.:frowning:



I’ve encountered an issue (or feature?) with setSelected method too. It just doesn’t change the _state member of Control object.

Managed to get desirable result with adding this if-else block in setSelected method:

void ControlButton::setSelected(bool enabled)
    if (enabled == true)
       _state = Control::State::SELECTED;
       _state = Control::State::NORMAL;