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

emscripten: replace shell_minimal.html with 'soft fullscreen' version #2498

Closed
wants to merge 1 commit into from

Conversation

floooh
Copy link
Contributor

@floooh floooh commented Apr 15, 2019

This PR replaces the default shell_minimal.html in the new emscripten example with a more minimal version which stretches the WebGL canvas over the whole window client rectangle.

printf-output is routed to the Javascript console in the browser devtools.

Here's the code as live sample:

http://floooh.github.io/oryol-sticky-tests/emsc-imgui-test/example_emscripten.html

Note however that the text rendering still appears filtered, despite the "upscale-filtering" in the WebGL canvas disabled via CSS. This is because the font texture is created with GL_LINEAR filtering. In my own ImGui samples (https://floooh.github.io/sokol-html5/) I'm using GL_NEAREST for the sample which renders "LowDPI" and with the default font, and GL_LINEAR for the other sample which uses HighDPI rendering and another TTF font.

I think it's better to keep the texture creation as is, and live with the somewhat "foggy" text(?) (some elements look better when smoothed, for instance the top-left triangle and the checkmarks.

Oh, and the canvas resizing was already handled correctly in imgui_impl_sdl.cpp, SDL_GetWindowSize() returns the size of the WebGL canvas, and this is forwarded to ImGui's DisplaySize.

@ocornut
Copy link
Owner

ocornut commented Apr 17, 2019

Merged this, thank you!

Do you know if it is possible to somehow get the ALT key working (for keyboard access to menu menus) ?

(Stretch goal: Ctrl+Tab.. probably is even more difficult.)

@ocornut ocornut closed this Apr 17, 2019
@floooh
Copy link
Contributor Author

floooh commented Apr 17, 2019

Do you know if it is possible to somehow get the ALT key working (for keyboard access to menu menus) ?

This should be possible, at least I can get the Alt, Ctrl and Cmd key on Mac show up in my input-test demo here: http://floooh.github.io/oryol/asmjs/TestInput.html

Ctrl+Tab may be a bit trickier, because that's also the browsers tab-switching... I don't know yet whether this can be hijacked. I had a somewhat similar problem with F1, which in Chrome on Windows opens the browsers Help, but could be fixed by consuming the event (not forwarding it to the browser). I don't know if this can also be done for combinations like Ctrl-Tab.

I also don't know yet if the SDL2 wrapper provides this sort of control on emscripten. I'll try to figure this out when I'm doing the PR for the "mini-emscripten-demo", it will be a few days.

@floooh
Copy link
Contributor Author

floooh commented Apr 17, 2019

...hm stupid question, but how I can test the ALT-key menu navigation?

When you go to the demo:

http://floooh.github.io/oryol-sticky-tests/emsc-imgui-test/example_emscripten.html

...and open "Inputs, Navigation & Focus..." => "Keyboard, Mouse and Navigation State", I see that Alt and Ctrl are recognized (tested on Windows and Mac), so they're already forwarded to ImGui, but the menu doesn't open.

Ctrl-Tab with only a single browser tab open currently seems to be broken (the Ctrl-Key gets stuck), so I need to figure that one out somehow...

@ocornut
Copy link
Owner

ocornut commented Apr 17, 2019

Demo -> Configuration -> NavEnableKeyboard for keyboard navigation.

Alt appears to be seen, the problem is in this case the browser's menu end up stealing focus which makes it unusable. I really this is a highish bar but it'd be nice to have keyboard control working there.

@floooh
Copy link
Contributor Author

floooh commented Apr 17, 2019

Aha, neat :) I totally wasn't aware of the keyboard navigation stuff :)

Which browser and OS are you testing on? On Mac it seems to work fine in Chrome, Firefox and Safari.

On Windows7 it works in Chrome, but in Firefox I'm indeed seeing the Firefox-application-menu pop up when pressing Alt.

I'm not sure yet whether this can be fixed, in my sokol-samples I'm already "consuming" the Alt-key-event in my keyboard event handler function, yet Firefox still shows the menu bar when pressing Alt. I'll look around whether I can find a solution.

@floooh
Copy link
Contributor Author

floooh commented Apr 17, 2019

Hmm, the issue seems indeed be specific to Firefox, there's a 10-year-long debate here whether a webpage should be allowed to suppress standard hotkeys in Firefox. Apparently the debate is "resolved" now, but I haven't found the comment yet with the decision:

https://bugzilla.mozilla.org/show_bug.cgi?id=380637

@ocornut ocornut added the web label Jul 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants