diff options
| author | Andre Weissflog <floooh@gmail.com> | 2024-01-27 14:24:43 +0100 |
|---|---|---|
| committer | Andre Weissflog <floooh@gmail.com> | 2024-01-27 14:24:43 +0100 |
| commit | b3468660e0b69edc2f6505765ce57174ffa19cc9 (patch) | |
| tree | 159b645cb8c2636799ed3854ab1024764c42d757 | |
| parent | 05f6087d8a9332dfccf00ae4b8965cbdc0564880 (diff) | |
sokol_app.h: add doc section about html5 event bubbling behaviour and control
| -rw-r--r-- | sokol_app.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/sokol_app.h b/sokol_app.h index 3746a093..0693fb89 100644 --- a/sokol_app.h +++ b/sokol_app.h @@ -946,6 +946,42 @@ keyboards work for on web applications that don't use HTML UIs never really worked across browsers). + INPUT EVENT BUBBLING ON THE WEB PLATFORM + ======================================== + By default, input event bubbling on the web platform is configured in + a way that makes the most sense for 'full-canvas' apps that cover the + entire browser client window area: + + - mouse, touch and wheel events do not bubble up, this prevents various + ugly side events, like: + - HTML text overlays being selected on double- or triple-click into + the canvas + - 'scroll bumping' even when the canvas covers the entire client area + - key_up/down events for 'character keys' *do* bubble up (otherwise + the browser will not generate UNICODE character events) + - all other key events *do not* bubble up by default (this prevents side effects + like F1 opening help, or F7 starting 'caret browsing') + - character events do no bubble up (although I haven't noticed any side effects + otherwise) + + Event bubbling can be enabled for input event categories during initialization + in the sapp_desc struct: + + sapp_desc sokol_main(int argc, char* argv[]) { + return (sapp_desc){ + //... + .html5_bubble_mouse_events = true, + .html5_bubble_touch_events = true, + .html5_bubble_wheel_events = true, + .html5_bubble_key_events = true, + .html5_bubble_char_events = true, + }; + } + + This basically opens the floodgates lets *all* input events bubble up to the browser. + To prevent individual events from bubbling, call sapp_consume_event() from within + the sokol_app.h event callback. + OPTIONAL: DON'T HIJACK main() (#define SOKOL_NO_ENTRY) ====================================================== NOTE: SOKOL_NO_ENTRY and sapp_run() is currently not supported on Android. |