Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

press 'A' button on xbox console Edge browser doesnt trigger anything #45

Open
kennyma603 opened this issue Nov 23, 2017 · 1 comment
Open

Comments

@kennyma603
Copy link

I was using exactly the same code from https://raw.githubusercontent.com/Microsoft/TVHelpers/master/tvjs/examples/DirectionalNavigation/ModalDialog/ModalDialog.html

the only different was i added <script src="gamepadtokey-1.0.0.0.js"></script> before directionalnavigation-1.0.0.0.js script tag, because i wanted to use xbox controller.

serve ModalDialog.html using a local server, then on xbox, open up edge broswer, then load ModalDialog.html (using ip address, eg: 10.10.10.123:7000/ModalDialog.html)

try to press open modal button, nothing happen.

i did some debugging, press 'A' button on controller hit line 603 from directionalnavigation-1.0.0.0.js

i did "alert(e.srcElement.outerHTML);" for debugging.
it turns out no matter where you click A, on a button or input field, the e.srcElemetn is always .
and e.srcElement.click(); would not work.

function _handleKeyUpEvent(e) {
    alert(e.srcElement.outerHTML);
    if (e.defaultPrevented) {
        return;
    }
    if (_keyCodeMap.accept.indexOf(e.keyCode) !== -1) {
        e.srcElement.click();
    }
};

i guess the problem is on the gamepadtokey.js,

function raiseEvent(name, key, keyCode) {
    var event = document.createEvent('Event');
    event.initEvent(name, true, true);
    event.key = key;
    event.keyCode = keyCode;
    document.body.dispatchEvent(event);
};

the event is always trigger from document body, not the element that you are actually on.

is it a bug? or intended?

index.txt

@kennyma603
Copy link
Author

function _handleKeyUpEvent(e) {
    if (e.defaultPrevented) {
        return;
    }
    if (_keyCodeMap.accept.indexOf(e.keyCode) !== -1) {
        e.srcElement.click();
        //document.activeElement.click();
    }
};

changing e.srcElement.click(); to document.activeElement.click(); would work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant