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

sokol_nuklear.h: change snk_handle_event to return a bool if handled #959

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions util/sokol_nuklear.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
Loading