Change action handler

This commit is contained in:
Tamius Han 2020-10-21 23:52:16 +02:00
parent 7fb9aad0d0
commit 28c12861e5

View File

@ -104,14 +104,36 @@ class ActionHandler {
}
}
document.addEventListener('keydown', (event) => ths.handleKeydown(event) );
document.addEventListener('keyup', (event) => ths.handleKeyup(event) );
// events should be handled in handleEvent function. We need to do things this
// way, otherwise we can't remove event listenerđ
// https://stackoverflow.com/a/19507086
document.addEventListener('keydown', this );
document.addEventListener('keyup', this );
this.pageInfo.setActionHandler(this);
this.logger.log('info', 'debug', "[ActionHandler::init] initialization complete");
}
handleEvent(event) {
switch(event.type) {
case 'keydown':
this.handleKeydown(event);
break;
case 'keyup':
this.handleKeyup(event);
break;
case 'mousemove':
this.handleMouseMove(event);
break;
}
}
destroy() {
document.removeEventListener('keydown', this);
document.removeEventListener('keyup', this);
}
registerHandleMouse(videoData) {
this.logger.log('info', ['actionHandler', 'mousemove'], "[ActionHandler::registerHandleMouse] registering handle mouse for videodata:", videoData.id)