@@ -23500,7 +23500,8 @@ nk_widget_is_hovered(const struct nk_context *ctx)
2350023500 struct nk_rect bounds;
2350123501 NK_ASSERT(ctx);
2350223502 NK_ASSERT(ctx->current);
23503- if (!ctx || !ctx->current || ctx->active != ctx->current)
23503+ NK_ASSERT(ctx->current->layout);
23504+ if (!ctx || !ctx->current || !ctx->current->layout || (ctx->active != ctx->current && !((int)ctx->current->layout->type & (int)NK_PANEL_SET_POPUP)))
2350423505 return 0;
2350523506
2350623507 c = ctx->current->layout->clip;
@@ -23522,7 +23523,8 @@ nk_widget_is_mouse_clicked(const struct nk_context *ctx, enum nk_buttons btn)
2352223523 struct nk_rect bounds;
2352323524 NK_ASSERT(ctx);
2352423525 NK_ASSERT(ctx->current);
23525- if (!ctx || !ctx->current || ctx->active != ctx->current)
23526+ NK_ASSERT(ctx->current->layout);
23527+ if (!ctx || !ctx->current || !ctx->current->layout || (ctx->active != ctx->current && !((int)ctx->current->layout->type & (int)NK_PANEL_SET_POPUP)))
2352623528 return 0;
2352723529
2352823530 c = ctx->current->layout->clip;
@@ -23544,7 +23546,8 @@ nk_widget_has_mouse_click_down(const struct nk_context *ctx, enum nk_buttons btn
2354423546 struct nk_rect bounds;
2354523547 NK_ASSERT(ctx);
2354623548 NK_ASSERT(ctx->current);
23547- if (!ctx || !ctx->current || ctx->active != ctx->current)
23549+ NK_ASSERT(ctx->current->layout);
23550+ if (!ctx || !ctx->current || !ctx->current->layout || (ctx->active != ctx->current && !((int)ctx->current->layout->type & (int)NK_PANEL_SET_POPUP)))
2354823551 return 0;
2354923552
2355023553 c = ctx->current->layout->clip;
@@ -23805,13 +23808,16 @@ nk_widget_text(struct nk_command_buffer *o, struct nk_rect b,
2380523808 if (!o || !t) return;
2380623809
2380723810 b.h = NK_MAX(b.h, 2 * t->padding.y);
23808- label.x = 0; label.w = 0;
23809- label.y = b.y + t->padding.y;
23810- label.h = NK_MIN(f->height, b.h - 2 * t->padding.y);
2381123811
2381223812 text_width = f->width(f->userdata, f->height, (const char*)string, len);
2381323813 text_width += (2.0f * t->padding.x);
2381423814
23815+ /* use top-left alignment by default */
23816+ if (!(a & (NK_TEXT_ALIGN_LEFT | NK_TEXT_ALIGN_CENTERED | NK_TEXT_ALIGN_RIGHT)))
23817+ a |= NK_TEXT_ALIGN_LEFT;
23818+ if (!(a & (NK_TEXT_ALIGN_TOP | NK_TEXT_ALIGN_MIDDLE | NK_TEXT_ALIGN_BOTTOM)))
23819+ a |= NK_TEXT_ALIGN_TOP;
23820+
2381523821 /* align in x-axis */
2381623822 if (a & NK_TEXT_ALIGN_LEFT) {
2381723823 label.x = b.x + t->padding.x;
@@ -23825,16 +23831,20 @@ nk_widget_text(struct nk_command_buffer *o, struct nk_rect b,
2382523831 } else if (a & NK_TEXT_ALIGN_RIGHT) {
2382623832 label.x = NK_MAX(b.x + t->padding.x, (b.x + b.w) - (2 * t->padding.x + (float)text_width));
2382723833 label.w = (float)text_width + 2 * t->padding.x;
23828- } else return;
23834+ }
2382923835
2383023836 /* align in y-axis */
23831- if (a & NK_TEXT_ALIGN_MIDDLE) {
23837+ if (a & NK_TEXT_ALIGN_TOP) {
23838+ label.y = b.y + t->padding.y;
23839+ label.h = NK_MIN(f->height, b.h - 2 * t->padding.y);
23840+ } else if (a & NK_TEXT_ALIGN_MIDDLE) {
2383223841 label.y = b.y + b.h/2.0f - (float)f->height/2.0f;
2383323842 label.h = NK_MAX(b.h/2.0f, b.h - (b.h/2.0f + f->height/2.0f));
2383423843 } else if (a & NK_TEXT_ALIGN_BOTTOM) {
2383523844 label.y = b.y + b.h - f->height;
2383623845 label.h = f->height;
2383723846 }
23847+
2383823848 nk_draw_text(o, label, (const char*)string, len, f, t->background, t->text);
2383923849}
2384023850NK_LIB void
@@ -30716,6 +30726,9 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
3071630726/// - [y]: Minor version with non-breaking API and library changes
3071730727/// - [z]: Patch version with no direct changes to the API
3071830728///
30729+ /// - 2025/10/08 (4.12.8) - Fix nk_widget_text to use NK_TEXT_ALIGN_LEFT by default,
30730+ /// instead of silently failing when no x-axis alignment is provided,
30731+ /// and refactor this function to keep the code style consistent
3071930732/// - 2025/09/12 (4.12.8) - Fix nk_window_is_hovered to use current window flags
3072030733 - Fix nk_utf_decode length check (allow len == NK_UTF_SIZE)
3072130734/// - 2025/04/06 (4.12.7) - Fix text input navigation and mouse scrolling
0 commit comments