rpgwizard icon indicating copy to clipboard operation
rpgwizard copied to clipboard

Activation KEYPRESS events not restoring previously global assigned key handlers

Open swordmaster2k opened this issue 5 years ago • 0 comments

It is possible to overwrite a global key handler such as the swordslash in the action battle system using a KEYPRESS based event. Once the event has finished running the key handler is not being restored.

The bug occurs in the character.js code:

    events.forEach(function (event) {
        if (event.program) {
            if (event.type.toUpperCase() === "OVERLAP") {
                rpgwizard.runProgram(PATH_PROGRAM.concat(event.program), object);
            } else if (event.type.toUpperCase() === "KEYPRESS") {
                if (event.key) {
                    entity.previousKeyHandler = {
                        key: event.key,
                        callback: rpgwizard.keyboardHandler.downHandlers[event.key]
                    };
                    var callback = function () {
                        rpgcode.unregisterKeyDown(event.key, true);
                        rpgwizard.runProgram(PATH_PROGRAM.concat(event.program), object);
                    };
                    rpgcode.registerKeyDown(event.key, callback, true);
                }
            }
        }
    });

swordmaster2k avatar Sep 28 '20 14:09 swordmaster2k