PDA

View Full Version : Question about signals and button entity



darkchazz
12-20-2013, 01:51 PM
Hi,

When I do this

ButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&MyOnSelectFunction);

Is there a way to disconnect it so I can connect it to another OnSelect function?

Basically I want to change what the button entity does without adding another button entity.

Thanks!



And one more thing: after updating my 2012 Nexus 7 to android 4.4 kitkat. There's a weird beep sound that occurs when I click any button entity :(

Yogi
12-21-2013, 09:39 PM
this should work

ButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.disconnect(&MyOnSelectFunction);

darkchazz
12-22-2013, 11:05 AM
this should work

ButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.disconnect(&MyOnSelectFunction);

Yes I have tried that before creating this thread.
It should work, except I'm calling it from within the "MyOnSelectFunction" when the button itself is clicked, and that does not work.

Is there a way around that? I need to disconnect it when the button is clicked.

Yogi
12-22-2013, 03:56 PM
I checked this and it works fine.

void ButtonAction(VariantList *pVList)
{
Entity *entityClicked = pVList->m_variant[1].GetEntity();
// function code ....

// disconect code
entityClicked->GetShared()->GetFunction("OnButtonSelected")->sig_function.disconnect(&ButtonAction);
}