-
Notifications
You must be signed in to change notification settings - Fork 16
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
Html5 support #47
Html5 support #47
Conversation
Checking now. |
} | ||
|
||
void defos_toggle_fullscreen() { | ||
js_warn("Method 'toggle_fullscreen' don't supported in html5, you can use Module.toggleFullscreen() method in JS"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not call Module.toggleFullscreen()
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, but :
Note: Fullscreen requests need to be called from within an event handler or otherwise they will be denied.
https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory we can use some hack like
Module.canvas.onclick = function()
{
Module.toggleFullscreen();
Module.canvas.onclick = "";
}
But this method would be work only in action.pressed and won't in action.released
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could technically queue it to some other event, like mouse moved, or to multiple events, but yeah, it's finicky. Maybe put it on a hidden button and .click()
it? I'm not sure that would work. I'll try out some things when I come back from work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked many variants (even emscripten_set_*_callback and so on)
I found only one way:
a hack with on_mouse_up (released) callback, but button should use action.pressed event then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I managed to sort of work around the issue after all. I added an defos.on_click()
event where the user can manually check if the mouse is clicking on his full screen button and then call defos.toggle_fullscreen()
from there. This will work because defos.on_click()
calls its callback inside the native HTML event handler.
} | ||
|
||
void defos_event_handler_was_set(DefosEvent event) { | ||
js_warn("Callbacks 'on_mouse_leave' and 'on_mouse_enter' don't supported in html5"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These could technically be implemented with Module.canvas.addEventListener('mouseenter')
and Module.canvas.addEventListener('mouseleave')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I know.
But we have no possability to call cpp method from JS. defold/extension-html5#1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should probably be safe to ccall()
it. Setting up lua contexts is done by defos_emit_event()
anyway. (And there's only one thread in JS anyway, so we have no such issues).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about that, but it was a deep night when i make experiments.
Let this Pull Request will be start of new platform, and we make some improvements step by step.
I will try ccall today after work, but I have to use some compilation parameters like EXPORTED_FUNCTIONS, i need to understand how to use them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed it in #48
Added support of HTML5 #24