vurtun/nuklear

Wrong combo behavior when NK_BUTTON_TRIGGER_ON_RELEASE is defined

kamil-zubair opened this issue · 5 comments

When NK_BUTTON_TRIGGER_ON_RELEASE is defined, combobox is opened when mouse button is release as it should be.
But when I clicked on opened combo box, it closed on mouse click and opened again on mouse released.
After debugging the code I found that the culprit is in function nk_nonblock_begin in line

pressed = nk_input_is_mouse_pressed(&ctx->input, NK_BUTTON_LEFT);

After I changed it to :

#ifdef NK_BUTTON_TRIGGER_ON_RELEASE
	pressed = nk_input_is_mouse_released(&ctx->input, NK_BUTTON_LEFT);
#else
        pressed = nk_input_is_mouse_pressed(&ctx->input, NK_BUTTON_LEFT);
#endif

the combo box works as intended.
Is this the right way to fix the issue ? Anyway, I hope the bug is fixed in the next release.

Feel free to search the issue history first - see e.g. #116 (comment) or #417 . Did it help to understand the difference?

The way I understand it is if I define NK_BUTTON_TRIGGER_ON_RELEASE, everything should be working the same way except that event is fire on mouse released instead of mouse pressed.

But this is not the case with combo box, without NK_BUTTON_TRIGGER_ON_RELEASE if I clicked on combo box header, the content is drawn and if clicked on the header again the content is closed.

But if I defined NK_BUTTON_TRIGGER_ON_RELEASE, the content is drawn when I clicked on the combo box header but if clicked on the header again the content is closed and immediately drawn again, the only way to close the combo box is to clicked outside of combo box area. Surely this is not the intended behaviour ?

Yeah, sounds a bit like bug - pull requests welcome 😉.

for my own usage I edit nuklear.h directly, but nk_nonblock_begin is originally in nuklear_popup.c, Which file should I edit for the pull request ? both or just nuklear_popup.c ?

Please edit nuklear_popup.c (we use amalgamation using src/paq.sh - see also src/Readme.md).