Skip to content

Commit 39da042

Browse files
add nk_edit_is_any_active() utility function
This small utility function returns `nk_true` when any EDIT field is active. SDL3 need this for hooking SDL_StartTextInput into the demo.
1 parent fcd64f8 commit 39da042

File tree

5 files changed

+22
-0
lines changed

5 files changed

+22
-0
lines changed

demo/common/overview.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,8 @@ overview(struct nk_context *ctx)
601601
static int box_len;
602602
nk_flags active;
603603

604+
nk_labelf(ctx, NK_TEXT_LEFT, "Any Input active: %s", nk_edit_is_any_active(ctx) ? "YES" : "no");
605+
604606
nk_layout_row(ctx, NK_STATIC, 25, 2, ratio);
605607
nk_label(ctx, "Default:", NK_TEXT_LEFT);
606608

nuklear.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3733,6 +3733,7 @@ NK_API nk_flags nk_edit_string_zero_terminated(struct nk_context*, nk_flags, cha
37333733
NK_API nk_flags nk_edit_buffer(struct nk_context*, nk_flags, struct nk_text_edit*, nk_plugin_filter);
37343734
NK_API void nk_edit_focus(struct nk_context*, nk_flags flags);
37353735
NK_API void nk_edit_unfocus(struct nk_context*);
3736+
NK_API nk_bool nk_edit_is_any_active(const struct nk_context*);
37363737
/* =============================================================================
37373738
*
37383739
* CHART
@@ -28664,7 +28665,15 @@ nk_edit_string_zero_terminated(struct nk_context *ctx, nk_flags flags,
2866428665
buffer[NK_MIN(NK_MAX(max-1,0), len)] = '\0';
2866528666
return result;
2866628667
}
28668+
NK_API nk_bool
28669+
nk_edit_is_any_active(const struct nk_context *ctx)
28670+
{
28671+
NK_ASSERT(ctx);
28672+
if (!ctx) return nk_false;
2866728673

28674+
return (ctx->active && ctx->active->edit.active) ||
28675+
(ctx->active && ctx->active->popup.win && ctx->active->popup.win->edit.active);
28676+
}
2866828677

2866928678

2867028679

@@ -30729,6 +30738,7 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
3072930738
/// - [y]: Minor version with non-breaking API and library changes
3073030739
/// - [z]: Patch version with no direct changes to the API
3073130740
///
30741+
/// - 2025/11/25 (4.13.0) - Added new utility function: nk_edit_is_any_active
3073230742
/// - 2025/10/08 (4.12.8) - Fix nk_widget_text to use NK_TEXT_ALIGN_LEFT by default,
3073330743
/// instead of silently failing when no x-axis alignment is provided,
3073430744
/// and refactor this function to keep the code style consistent

src/CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
/// - [y]: Minor version with non-breaking API and library changes
88
/// - [z]: Patch version with no direct changes to the API
99
///
10+
/// - 2025/11/25 (4.13.0) - Added new utility function: nk_edit_is_any_active
1011
/// - 2025/10/08 (4.12.8) - Fix nk_widget_text to use NK_TEXT_ALIGN_LEFT by default,
1112
/// instead of silently failing when no x-axis alignment is provided,
1213
/// and refactor this function to keep the code style consistent

src/nuklear.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3510,6 +3510,7 @@ NK_API nk_flags nk_edit_string_zero_terminated(struct nk_context*, nk_flags, cha
35103510
NK_API nk_flags nk_edit_buffer(struct nk_context*, nk_flags, struct nk_text_edit*, nk_plugin_filter);
35113511
NK_API void nk_edit_focus(struct nk_context*, nk_flags flags);
35123512
NK_API void nk_edit_unfocus(struct nk_context*);
3513+
NK_API nk_bool nk_edit_is_any_active(const struct nk_context*);
35133514
/* =============================================================================
35143515
*
35153516
* CHART

src/nuklear_edit.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,4 +833,12 @@ nk_edit_string_zero_terminated(struct nk_context *ctx, nk_flags flags,
833833
buffer[NK_MIN(NK_MAX(max-1,0), len)] = '\0';
834834
return result;
835835
}
836+
NK_API nk_bool
837+
nk_edit_is_any_active(const struct nk_context *ctx)
838+
{
839+
NK_ASSERT(ctx);
840+
if (!ctx) return nk_false;
836841

842+
return (ctx->active && ctx->active->edit.active) ||
843+
(ctx->active && ctx->active->popup.win && ctx->active->popup.win->edit.active);
844+
}

0 commit comments

Comments
 (0)