Skip to content

Commit 9851a51

Browse files
authored
Merge pull request #837 from lockie/hover-in-popup
Correctly handle hover in popup windows
2 parents 171090c + 1374197 commit 9851a51

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

nuklear.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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;

src/nuklear_widget.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ nk_widget_is_hovered(const struct nk_context *ctx)
7272
struct nk_rect bounds;
7373
NK_ASSERT(ctx);
7474
NK_ASSERT(ctx->current);
75-
if (!ctx || !ctx->current || ctx->active != ctx->current)
75+
NK_ASSERT(ctx->current->layout);
76+
if (!ctx || !ctx->current || !ctx->current->layout || (ctx->active != ctx->current && !((int)ctx->current->layout->type & (int)NK_PANEL_SET_POPUP)))
7677
return 0;
7778

7879
c = ctx->current->layout->clip;
@@ -94,7 +95,8 @@ nk_widget_is_mouse_clicked(const struct nk_context *ctx, enum nk_buttons btn)
9495
struct nk_rect bounds;
9596
NK_ASSERT(ctx);
9697
NK_ASSERT(ctx->current);
97-
if (!ctx || !ctx->current || ctx->active != ctx->current)
98+
NK_ASSERT(ctx->current->layout);
99+
if (!ctx || !ctx->current || !ctx->current->layout || (ctx->active != ctx->current && !((int)ctx->current->layout->type & (int)NK_PANEL_SET_POPUP)))
98100
return 0;
99101

100102
c = ctx->current->layout->clip;
@@ -116,7 +118,8 @@ nk_widget_has_mouse_click_down(const struct nk_context *ctx, enum nk_buttons btn
116118
struct nk_rect bounds;
117119
NK_ASSERT(ctx);
118120
NK_ASSERT(ctx->current);
119-
if (!ctx || !ctx->current || ctx->active != ctx->current)
121+
NK_ASSERT(ctx->current->layout);
122+
if (!ctx || !ctx->current || !ctx->current->layout || (ctx->active != ctx->current && !((int)ctx->current->layout->type & (int)NK_PANEL_SET_POPUP)))
120123
return 0;
121124

122125
c = ctx->current->layout->clip;

0 commit comments

Comments
 (0)