@@ -312,6 +312,28 @@ NK_API nk_bool nk_console_navigate_to_path(nk_console* console, const char* path
312312#ifndef NK_CONSOLE_IMPLEMENTATION_ONCE
313313#define NK_CONSOLE_IMPLEMENTATION_ONCE
314314
315+ #ifndef NK_BUTTON_TRIGGER_ON_RELEASE
316+ /**
317+ * Define NK_BUTTON_TRIGGER_ON_RELEASE prior to nuklear.h.
318+ *
319+ * This is required because the input events are triggered incorrectly otherwise.
320+ *
321+ * @code
322+ * #define NK_IMPLEMENTATION
323+ * #define NK_BUTTON_TRIGGER_ON_RELEASE
324+ * #include "nuklear.h"
325+ *
326+ * #define NK_CONSOLE_IMPLEMENTATION
327+ * #include "nuklear_console.h"
328+ * @endcode
329+ *
330+ * You are able to ignore this warning by using #define NK_CONSOLE_IGNORE_BUTTON_TRIGGER_ON_RELEASE
331+ */
332+ #ifndef NK_CONSOLE_IGNORE_BUTTON_TRIGGER_ON_RELEASE
333+ #warning nuklear_console requires NK_BUTTON_TRIGGER_ON_RELEASE. Define it directly prior to #include "nuklear.h" .
334+ #endif
335+ #endif
336+
315337#ifndef NK_CONSOLE_AXIS_DEADZONE
316338#define NK_CONSOLE_AXIS_DEADZONE 0.22f
317339#endif
@@ -880,10 +902,6 @@ static void nk_console_axis_update(nk_console* console) {
880902 * Handles the Touch and Drag Scrolling.
881903 */
882904static void nk_console_window_touch_drag (nk_console * console , nk_console_top_data * top_data ) {
883- #ifndef NK_BUTTON_TRIGGER_ON_RELEASE
884- NK_UNUSED (console );
885- NK_UNUSED (top_data );
886- #else
887905 struct nk_input * in = & console -> ctx -> input ;
888906 if (nk_window_is_hovered (console -> ctx ) && nk_input_is_mouse_pressed (in , NK_BUTTON_LEFT )) {
889907 top_data -> drag_scroll_origin = in -> mouse .pos ;
@@ -906,7 +924,6 @@ static void nk_console_window_touch_drag(nk_console* console, nk_console_top_dat
906924 } else {
907925 top_data -> drag_scroll_active = nk_false ;
908926 }
909- #endif
910927}
911928
912929NK_API void nk_console_render (nk_console * console ) {
@@ -1113,10 +1130,8 @@ NK_API struct nk_rect nk_console_render_window(nk_console* console, const char*
11131130 float rendered_h = console -> ctx -> current -> layout -> at_y - console -> ctx -> current -> layout -> bounds .y + console -> ctx -> current -> layout -> row .height ;
11141131 window_bounds = nk_window_get_bounds (console -> ctx );
11151132 window_bounds .h = window_bounds .h - content .h + rendered_h ;
1116- #ifdef NK_BUTTON_TRIGGER_ON_RELEASE
11171133 top_data -> drag_scroll_max_y = (nk_uint )NK_MAX (0.0f , rendered_h - content .h );
11181134 top_data -> drag_scroll_max_x = (nk_uint )NK_MAX (0.0f , console -> ctx -> current -> layout -> max_x - console -> ctx -> current -> layout -> bounds .x - content .w );
1119- #endif
11201135 }
11211136
11221137 // Finish the window processing.
0 commit comments