fix scrollbar dragging behavior, similar to #688

This commit is contained in:
diggit 2018-08-26 11:26:57 +02:00
parent b17df7b463
commit e86fcabce7
2 changed files with 6 additions and 2 deletions

View File

@ -21180,6 +21180,7 @@ nk_scrollbar_behavior(nk_flags *state, struct nk_input *in,
{
nk_flags ws = 0;
int left_mouse_down;
int left_mouse_clicked;
int left_mouse_click_in_cursor;
float scroll_delta;
@ -21187,13 +21188,14 @@ nk_scrollbar_behavior(nk_flags *state, struct nk_input *in,
if (!in) return scroll_offset;
left_mouse_down = in->mouse.buttons[NK_BUTTON_LEFT].down;
left_mouse_clicked = in->mouse.buttons[NK_BUTTON_LEFT].clicked;
left_mouse_click_in_cursor = nk_input_has_mouse_click_down_in_rect(in,
NK_BUTTON_LEFT, *cursor, nk_true);
if (nk_input_is_mouse_hovering_rect(in, *scroll))
*state = NK_WIDGET_STATE_HOVERED;
scroll_delta = (o == NK_VERTICAL) ? in->mouse.scroll_delta.y: in->mouse.scroll_delta.x;
if (left_mouse_down && left_mouse_click_in_cursor) {
if (left_mouse_down && left_mouse_click_in_cursor && !left_mouse_clicked) {
/* update cursor by mouse dragging */
float pixel, delta;
*state = NK_WIDGET_STATE_ACTIVE;

View File

@ -15,6 +15,7 @@ nk_scrollbar_behavior(nk_flags *state, struct nk_input *in,
{
nk_flags ws = 0;
int left_mouse_down;
int left_mouse_clicked;
int left_mouse_click_in_cursor;
float scroll_delta;
@ -22,13 +23,14 @@ nk_scrollbar_behavior(nk_flags *state, struct nk_input *in,
if (!in) return scroll_offset;
left_mouse_down = in->mouse.buttons[NK_BUTTON_LEFT].down;
left_mouse_clicked = in->mouse.buttons[NK_BUTTON_LEFT].clicked;
left_mouse_click_in_cursor = nk_input_has_mouse_click_down_in_rect(in,
NK_BUTTON_LEFT, *cursor, nk_true);
if (nk_input_is_mouse_hovering_rect(in, *scroll))
*state = NK_WIDGET_STATE_HOVERED;
scroll_delta = (o == NK_VERTICAL) ? in->mouse.scroll_delta.y: in->mouse.scroll_delta.x;
if (left_mouse_down && left_mouse_click_in_cursor) {
if (left_mouse_down && left_mouse_click_in_cursor && !left_mouse_clicked) {
/* update cursor by mouse dragging */
float pixel, delta;
*state = NK_WIDGET_STATE_ACTIVE;