diff options
| author | Andre Weissflog <floooh@gmail.com> | 2024-01-03 17:42:16 +0100 |
|---|---|---|
| committer | Andre Weissflog <floooh@gmail.com> | 2024-01-03 17:42:16 +0100 |
| commit | 896daabe8bc0bb28bed1b54932d89cd822685b78 (patch) | |
| tree | 5f2d8e08c8e532ae54ca547bc283341a02934481 | |
| parent | 9ee0a7dc102087b2d43748c572c5bfa06bbaff93 (diff) | |
| parent | 884e0f5489c34866d78cebc34a516f68482b6408 (diff) | |
Merge branch 'adamrt-nuklear-event-notify'
| -rw-r--r-- | CHANGELOG.md | 7 | ||||
| -rw-r--r-- | util/sokol_nuklear.h | 11 |
2 files changed, 15 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d5ca4de..320cc8d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ ## Updates +#### 03-Jan-2024 + +- sokol_nuklear.h: `snk_handle_event()` now returns a bool to indicate whether the + event was handled by Nuklear (this allows an application to skip its own event + handling if Nuklear already handled the event). Issue link: https://github.com/floooh/sokol/issues/958, + fixed in PR: https://github.com/floooh/sokol/pull/959. Many thanks to @adamrt for the PR! + #### 02-Jan-2024 Happy New Year! A couple of input-related changes in the sokol_app.h Emscripten backend: diff --git a/util/sokol_nuklear.h b/util/sokol_nuklear.h index 92db25e9..25293252 100644 --- a/util/sokol_nuklear.h +++ b/util/sokol_nuklear.h @@ -145,7 +145,11 @@ --- if you're using sokol_app.h, from inside the sokol_app.h event callback, call: - void snk_handle_event(const sapp_event* ev); + bool snk_handle_event(const sapp_event* ev); + + This will feed the event into Nuklear's event handling code, and return + true if the event was handled by Nuklear, or false if the event should + be handled by the application. --- finally, on application shutdown, call @@ -436,7 +440,7 @@ SOKOL_NUKLEAR_API_DECL snk_image_desc_t snk_query_image_desc(snk_image_t img); SOKOL_NUKLEAR_API_DECL nk_handle snk_nkhandle(snk_image_t img); SOKOL_NUKLEAR_API_DECL snk_image_t snk_image_from_nkhandle(nk_handle handle); #if !defined(SOKOL_NUKLEAR_NO_SOKOL_APP) -SOKOL_NUKLEAR_API_DECL void snk_handle_event(const sapp_event* ev); +SOKOL_NUKLEAR_API_DECL bool snk_handle_event(const sapp_event* ev); SOKOL_NUKLEAR_API_DECL nk_flags snk_edit_string(struct nk_context *ctx, nk_flags flags, char *memory, int *len, int max, nk_plugin_filter filter); #endif SOKOL_NUKLEAR_API_DECL void snk_shutdown(void); @@ -2526,7 +2530,7 @@ _SOKOL_PRIVATE enum nk_keys _snk_event_to_nuklearkey(const sapp_event* ev) { } } -SOKOL_API_IMPL void snk_handle_event(const sapp_event* ev) { +SOKOL_API_IMPL bool snk_handle_event(const sapp_event* ev) { SOKOL_ASSERT(_SNK_INIT_COOKIE == _snuklear.init_cookie); const float dpi_scale = _snuklear.desc.dpi_scale; switch (ev->type) { @@ -2644,6 +2648,7 @@ SOKOL_API_IMPL void snk_handle_event(const sapp_event* ev) { default: break; } + return nk_item_is_any_active(&_snuklear.ctx); } SOKOL_API_IMPL nk_flags snk_edit_string(struct nk_context *ctx, nk_flags flags, char *memory, int *len, int max, nk_plugin_filter filter) { |