check if delegate is not null when dispatching keyboard event

This commit is contained in:
Rene Klacan 2013-06-10 00:54:31 +02:00
parent ef6841b532
commit 83be06bafb
1 changed files with 6 additions and 2 deletions

View File

@ -54,14 +54,18 @@ void CCKeyboardDispatcher::setKeyReleaseDelegate(CCKeyboardDelegate delegate)
bool CCKeyboardDispatcher::dispatchKeyboardEvent(int keyCode, bool pressed)
{
if (pressed)
if (m_keyPressDelegate != NULL && pressed)
{
m_keyPressDelegate(keyCode);
}
else
else if (m_keyReleaseDelegate != NULL)
{
m_keyReleaseDelegate(keyCode);
}
else
{
return false;
}
return true;
}