Keyboard Focus Issue

19 views
Skip to first unread message

J Decker

unread,
May 27, 2019, 3:12:26 PM5/27/19
to emscripten-discuss
I have this C app, which shows a application window in an opengl context on a canvas.
I have support for whether a mouse event is used or not, and just return that status out... 
When I click on the application form in the edit box, the form of course 'uses' the mouse event to set focus to itself and show the I-bar, etc... but becaues this mouse event gets consumed, the canvas control doesn't actually get focus, so when I type it doesn't get any key input events.  I have to click in the blank area around the form where the mouse event is not 'used', then I'm able to enter keys.


J Decker

unread,
May 28, 2019, 1:12:07 AM5/28/19
to emscripten-discuss
This really seems counter intuitive to me... 
if I click on the form, and use the mouse (click?) event in the edit field, to set the cursor to type there... then the canvas (full window, with glClear(0,0,0,0) ), does not get focus...  I did just double check, and it returns 1 if used and 0 if not used (it was 0 and not-0, but I squashed it to 0 and 1).

but if I click on the outside beyond the frame, where I'm not using the mouse click(?) event, then I get mouse focus?, and the event get passed to the page behind it( I can double click and select words in the div behind the canvas, when the mouse isn't on the frame)

when I click on the 'unused' canvas area, I do see a blue selection/active border light up... but not if I use the event.
image.png
 

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/12b82f16-8f0a-4ee1-b544-403e81bb61bd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

J Decker

unread,
May 28, 2019, 5:14:38 AM5/28/19
to emscripten-discuss


On Monday, May 27, 2019 at 10:12:07 PM UTC-7, J Decker wrote:


On Mon, May 27, 2019 at 12:12 PM J Decker <d3c...@gmail.com> wrote:
I have this C app, which shows a application window in an opengl context on a canvas.
I have support for whether a mouse event is used or not, and just return that status out... 
When I click on the application form in the edit box, the form of course 'uses' the mouse event to set focus to itself and show the I-bar, etc... but becaues this mouse event gets consumed, the canvas control doesn't actually get focus, so when I type it doesn't get any key input events.  I have to click in the blank area around the form where the mouse event is not 'used', then I'm able to enter keys.

This really seems counter intuitive to me... 
if I click on the form, and use the mouse (click?) event in the edit field, to set the cursor to type there... then the canvas (full window, with glClear(0,0,0,0) ), does not get focus...  I did just double check, and it returns 1 if used and 0 if not used (it was 0 and not-0, but I squashed it to 0 and 1).

but if I click on the outside beyond the frame, where I'm not using the mouse click(?) event, then I get mouse focus?, and the event get passed to the page behind it( I can double click and select words in the div behind the canvas, when the mouse isn't on the frame)

when I click on the 'unused' canvas area, I do see a blue selection/active border light up... but not if I use the event.

I guess HTML Canvas(UI Controls) don't really support click-through focus.... I did some searching after reflecting about using canvas/svg for clickthrough.

This is the least code sort of solution... 

There is CSS `pointer-events: none;`(or auto) and on SVG elements also 'stroke' and 'fill'.

I wonder where I would complain to get a css pointer-events : .... 'soft' ? 'mouse?' is is already pointer something so... something like 'if the control doesn't use it'
 
 

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.

Floh

unread,
May 28, 2019, 7:25:46 AM5/28/19
to emscripten-discuss
Not sure if it will fix your problems, but in my code I'm adding all mouse- and touch-event-handlers to the WebGL canvas, and the keyboard events to the target window context.


...and then only forward specific keys to the browser (to avoid things like arrow-up/down keys scrolling the webpage):


...it took a bit of trial and error to figure that all out though.

Cheers,
-Floh.
Reply all
Reply to author
Forward
0 new messages