diff --git a/nuklear.h b/nuklear.h index 61c7d8a7..a1fa9d1c 100644 --- a/nuklear.h +++ b/nuklear.h @@ -4933,6 +4933,7 @@ NK_API nk_bool nk_input_is_mouse_click_down_in_rect(const struct nk_input *i, en NK_API nk_bool nk_input_any_mouse_click_in_rect(const struct nk_input*, struct nk_rect); NK_API nk_bool nk_input_is_mouse_prev_hovering_rect(const struct nk_input*, struct nk_rect); NK_API nk_bool nk_input_is_mouse_hovering_rect(const struct nk_input*, struct nk_rect); +NK_API nk_bool nk_input_is_mouse_moved(const struct nk_input*); NK_API nk_bool nk_input_mouse_clicked(const struct nk_input*, enum nk_buttons, struct nk_rect); NK_API nk_bool nk_input_is_mouse_down(const struct nk_input*, enum nk_buttons); NK_API nk_bool nk_input_is_mouse_pressed(const struct nk_input*, enum nk_buttons); @@ -18434,6 +18435,12 @@ nk_input_is_mouse_released(const struct nk_input *i, enum nk_buttons id) return (!i->mouse.buttons[id].down && i->mouse.buttons[id].clicked); } NK_API nk_bool +nk_input_is_mouse_moved(const struct nk_input *i) +{ + if (!i) return nk_false; + return i->mouse.delta.x != 0 || i->mouse.delta.y != 0; +} +NK_API nk_bool nk_input_is_key_pressed(const struct nk_input *i, enum nk_keys key) { const struct nk_key *k; @@ -20381,7 +20388,7 @@ nk_panel_end(struct nk_context *ctx) /* hide scroll if no user input */ if (window->flags & NK_WINDOW_SCROLL_AUTO_HIDE) { - int has_input = ctx->input.mouse.delta.x != 0 || ctx->input.mouse.delta.y != 0 || ctx->input.mouse.scroll_delta.y != 0; + int has_input = nk_input_is_mouse_moved(&ctx->input) || ctx->input.mouse.scroll_delta.y != 0; int is_window_hovered = nk_window_is_hovered(ctx); int any_item_active = (ctx->last_widget_state & NK_WIDGET_STATE_MODIFIED); if ((!has_input && is_window_hovered) || (!is_window_hovered && !any_item_active)) @@ -28056,7 +28063,7 @@ nk_do_edit(nk_flags *state, struct nk_command_buffer *out, in->mouse.buttons[NK_BUTTON_LEFT].clicked) { nk_textedit_click(edit, mouse_x, mouse_y, font, row_height); } else if (is_hovered && in->mouse.buttons[NK_BUTTON_LEFT].down && - (in->mouse.delta.x != 0.0f || in->mouse.delta.y != 0.0f)) { + nk_input_is_mouse_moved(in)) { nk_textedit_drag(edit, mouse_x, mouse_y, font, row_height); cursor_follow = nk_true; } else if (is_hovered && in->mouse.buttons[NK_BUTTON_RIGHT].clicked && diff --git a/src/nuklear.h b/src/nuklear.h index 9b526566..9362e816 100644 --- a/src/nuklear.h +++ b/src/nuklear.h @@ -4710,6 +4710,7 @@ NK_API nk_bool nk_input_is_mouse_click_down_in_rect(const struct nk_input *i, en NK_API nk_bool nk_input_any_mouse_click_in_rect(const struct nk_input*, struct nk_rect); NK_API nk_bool nk_input_is_mouse_prev_hovering_rect(const struct nk_input*, struct nk_rect); NK_API nk_bool nk_input_is_mouse_hovering_rect(const struct nk_input*, struct nk_rect); +NK_API nk_bool nk_input_is_mouse_moved(const struct nk_input*); NK_API nk_bool nk_input_mouse_clicked(const struct nk_input*, enum nk_buttons, struct nk_rect); NK_API nk_bool nk_input_is_mouse_down(const struct nk_input*, enum nk_buttons); NK_API nk_bool nk_input_is_mouse_pressed(const struct nk_input*, enum nk_buttons); diff --git a/src/nuklear_edit.c b/src/nuklear_edit.c index 4106cf87..ae5daed0 100644 --- a/src/nuklear_edit.c +++ b/src/nuklear_edit.c @@ -232,7 +232,7 @@ nk_do_edit(nk_flags *state, struct nk_command_buffer *out, in->mouse.buttons[NK_BUTTON_LEFT].clicked) { nk_textedit_click(edit, mouse_x, mouse_y, font, row_height); } else if (is_hovered && in->mouse.buttons[NK_BUTTON_LEFT].down && - (in->mouse.delta.x != 0.0f || in->mouse.delta.y != 0.0f)) { + nk_input_is_mouse_moved(in)) { nk_textedit_drag(edit, mouse_x, mouse_y, font, row_height); cursor_follow = nk_true; } else if (is_hovered && in->mouse.buttons[NK_BUTTON_RIGHT].clicked && diff --git a/src/nuklear_input.c b/src/nuklear_input.c index 48ad5866..9480a522 100644 --- a/src/nuklear_input.c +++ b/src/nuklear_input.c @@ -253,6 +253,12 @@ nk_input_is_mouse_released(const struct nk_input *i, enum nk_buttons id) return (!i->mouse.buttons[id].down && i->mouse.buttons[id].clicked); } NK_API nk_bool +nk_input_is_mouse_moved(const struct nk_input *i) +{ + if (!i) return nk_false; + return i->mouse.delta.x != 0 || i->mouse.delta.y != 0; +} +NK_API nk_bool nk_input_is_key_pressed(const struct nk_input *i, enum nk_keys key) { const struct nk_key *k; diff --git a/src/nuklear_panel.c b/src/nuklear_panel.c index ce28b1aa..8fed2399 100644 --- a/src/nuklear_panel.c +++ b/src/nuklear_panel.c @@ -486,7 +486,7 @@ nk_panel_end(struct nk_context *ctx) /* hide scroll if no user input */ if (window->flags & NK_WINDOW_SCROLL_AUTO_HIDE) { - int has_input = ctx->input.mouse.delta.x != 0 || ctx->input.mouse.delta.y != 0 || ctx->input.mouse.scroll_delta.y != 0; + int has_input = nk_input_is_mouse_moved(&ctx->input) || ctx->input.mouse.scroll_delta.y != 0; int is_window_hovered = nk_window_is_hovered(ctx); int any_item_active = (ctx->last_widget_state & NK_WIDGET_STATE_MODIFIED); if ((!has_input && is_window_hovered) || (!is_window_hovered && !any_item_active))