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

Mouse callback with document as target fails with TypeError #3060

Closed
Daft-Freak opened this issue Dec 9, 2014 · 5 comments
Closed

Mouse callback with document as target fails with TypeError #3060

Daft-Freak opened this issue Dec 9, 2014 · 5 comments

Comments

@Daft-Freak
Copy link
Collaborator

Registering an event callback with the document as the target:

emscripten_set_mouseup_callback("#document", data, 0, HandleMouseButton);

Fails with error:

TypeError: target.getBoundingClientRect is not a function
@kripken
Copy link
Member

kripken commented Dec 9, 2014

Got a testcase? A naive attempt does not show any error:

#include<stdio.h>
#include<html5.h>

int HandleMouseButton(int z, const EmscriptenMouseEvent *y, void * x) {
  return 0;
}

int main() {
  emscripten_set_mouseup_callback("#document", NULL, 0, HandleMouseButton);
  return 0;
}

@Daft-Freak
Copy link
Collaborator Author

Should have mentioned that the error happens when the event is generated. Adding a loop seems to be enough for a testcase:

#include<stdio.h>
#include<html5.h>
#include<emscripten.h>

int HandleMouseButton(int z, const EmscriptenMouseEvent *y, void * x) {
  return 0;
}

void loop() {
}

int main() {
  emscripten_set_mouseup_callback("#document", NULL, 0, HandleMouseButton);
  emscripten_set_main_loop(loop, 0, 1);
  return 0;
}

@kripken
Copy link
Member

kripken commented Dec 10, 2014

I still don't see a crash on that. Which version of emscripten are you on? And on which browser and version do you see the problem?

@juj juj added the HTML5 API label Dec 10, 2014
@Daft-Freak
Copy link
Collaborator Author

Emscripten 1.27.1, Firefox 34. Exception thrown on every click.

kripken added a commit that referenced this issue Dec 11, 2014
@kripken
Copy link
Member

kripken commented Dec 11, 2014

Ok, I see it now. Looks like the HTML document itself doesn't have that method, just like the window. Fixed on incoming.

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

No branches or pull requests

3 participants