Run-Time Check Failure CCControlButton

I’m trying to create a radio button menu for my Level editor. I’m using cocos2d-2.1beta3-x-2.1.0 @ Dec 05 2012. I put a break point inside the touchDownAction and found out that it is being called when I pressed the button but after that it fire up a run-time check failure. It points on this code.

void CCInvocation::invoke(CCObject* sender)
{
if (m_target && m_action)
{
(m_target~~>m_action);
}
}
Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
Any help? The code below is the radiomenu I’m trying to test.
RadioMenu::RadioMenu
{
previousSelected = NULL;
}
>
CCControlButton
RadioMenu::createRadioButton
{
CCScale9Sprite buttonNormal = CCScale9Sprite::spriteWithSpriteFrameName;
CCScale9Sprite
buttonSelectedButton = CCScale9Sprite::spriteWithSpriteFrameName;
>
buttonNormal~~>setPreferredSize( CCSizeMake( 40, 40 ) );
buttonSelectedButton~~>setPreferredSize );
>
CCControlButton *controlButton = CCControlButton::create;
controlButton~~>setPosition( position );
controlButton~~>setAdjustBackgroundImage;
controlButton~~>setBackgroundSpriteForState( buttonSelectedButton, CCControlStateSelected );
controlButton~~>addTargetWithActionForControlEvents, CCControlEventTouchDown );
>
return controlButton;
}
>
void RadioMenu::touchDownAction
{
if
{
previousSelected~~>setSelected(false);
}
>
sender->setSelected(true);
previousSelected= sender;
}

Thank you
Dark66

Hi, I have the same kind of issue, did you find the solution?

For toggle buttons:
CCControlButtons wont’ even set the state to selected (it currently sets a bool) and even if it did, highlighted/disabled image will overwrite it when it enters those states

It seems these CCControls and CCScale9Sprite classes are rather half-baked and are poorly implemented, probably better to make your own, unless you can live with the basic functionality.

I got the same error when the function action is not right defined.

The function callback can’t be that way:
void CCInvocation::invoke(CCObject* sender)
it shoud be like this
void CCInvocation::invoke(CCObject *senderz, CCControlEvent controlEvent)

Following the CCControlButtonTest

controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(CCControlButtonTest_Event::touchCancelAction), CCControlEventTouchCancel);

void CCControlButtonTest_Event::touchCancelAction(CCObject *sender, CCControlEvent controlEvent)