Newer
Older
ButtonEventDispatcher::ButtonEventDispatcher()
:callbackFuncPtr{}
{}
void ButtonEventDispatcher::Dispatch(const ButtonEvent& e) const {
for (size_t i = 0 ; i < capacity; i++) {
if (callbackFuncPtr[i]) callbackFuncPtr[i](e);
}
}
void ButtonEventDispatcher::RegisterButtonHandler(void (*handler)(const ButtonEvent& e)) {
for (size_t i = 0 ; i < capacity; i++) {
if (!callbackFuncPtr[i]) {
callbackFuncPtr[i] = handler;
break;
}
}
}
void ButtonEventDispatcher::UnregisterButtonHandler(void (*handler)(const ButtonEvent& e)) {
for (size_t i = 0 ; i < capacity; i++) {
if (callbackFuncPtr[i] == handler) {
callbackFuncPtr[i] = nullptr;
}
}
}