From 383d0f94bd2c294c73fb4a47ae0a51945dd3b019 Mon Sep 17 00:00:00 2001 From: Vinh Truong Date: Sun, 10 Jul 2016 10:14:29 +0300 Subject: [PATCH] Change popup toggling semantics For gui elements like tree tabs, tree nodes and windows themselves, you can repeatedly click the same "minimize" region and it keeps toggling that element. This was not the case with "popup" type of elements. This commit slightly changes how the popups close once they are already open. Like before, the user can close the popup by just clicking outside the popups region. Now the user can also close the popup by clicking the "header" region of the popup. --- nuklear.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/nuklear.h b/nuklear.h index b4279c0d..19c4824c 100644 --- a/nuklear.h +++ b/nuklear.h @@ -18639,13 +18639,13 @@ nk_nonblock_begin(struct nk_panel *layout, struct nk_context *ctx, win->popup.win = popup; nk_command_buffer_init(&popup->buffer, &ctx->memory, NK_CLIPPING_ON); } else { - /* check if user clicked outside the popup and close if so */ - int clicked, in_body, in_header; - clicked = nk_input_has_mouse_click(&ctx->input, NK_BUTTON_LEFT); - in_body = nk_input_is_mouse_click_in_rect(&ctx->input, NK_BUTTON_LEFT, body); - in_header = nk_input_is_mouse_click_in_rect(&ctx->input, NK_BUTTON_LEFT, header); + /* close the popup if user pressed outside or in the header */ + int pressed, in_body, in_header; + pressed = nk_input_is_mouse_pressed(&ctx->input, NK_BUTTON_LEFT); + in_body = nk_input_is_mouse_hovering_rect(&ctx->input, body); + in_header = nk_input_is_mouse_hovering_rect(&ctx->input, header); - if (clicked && !in_body && !in_header) + if (pressed && (!in_body || in_header)) is_active = nk_false; }