fix scrollbar dragging behavior, similar to #688
parent
b17df7b463
commit
e86fcabce7
|
@ -21180,6 +21180,7 @@ nk_scrollbar_behavior(nk_flags *state, struct nk_input *in,
|
||||||
{
|
{
|
||||||
nk_flags ws = 0;
|
nk_flags ws = 0;
|
||||||
int left_mouse_down;
|
int left_mouse_down;
|
||||||
|
int left_mouse_clicked;
|
||||||
int left_mouse_click_in_cursor;
|
int left_mouse_click_in_cursor;
|
||||||
float scroll_delta;
|
float scroll_delta;
|
||||||
|
|
||||||
|
@ -21187,13 +21188,14 @@ nk_scrollbar_behavior(nk_flags *state, struct nk_input *in,
|
||||||
if (!in) return scroll_offset;
|
if (!in) return scroll_offset;
|
||||||
|
|
||||||
left_mouse_down = in->mouse.buttons[NK_BUTTON_LEFT].down;
|
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,
|
left_mouse_click_in_cursor = nk_input_has_mouse_click_down_in_rect(in,
|
||||||
NK_BUTTON_LEFT, *cursor, nk_true);
|
NK_BUTTON_LEFT, *cursor, nk_true);
|
||||||
if (nk_input_is_mouse_hovering_rect(in, *scroll))
|
if (nk_input_is_mouse_hovering_rect(in, *scroll))
|
||||||
*state = NK_WIDGET_STATE_HOVERED;
|
*state = NK_WIDGET_STATE_HOVERED;
|
||||||
|
|
||||||
scroll_delta = (o == NK_VERTICAL) ? in->mouse.scroll_delta.y: in->mouse.scroll_delta.x;
|
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 */
|
/* update cursor by mouse dragging */
|
||||||
float pixel, delta;
|
float pixel, delta;
|
||||||
*state = NK_WIDGET_STATE_ACTIVE;
|
*state = NK_WIDGET_STATE_ACTIVE;
|
||||||
|
|
|
@ -15,6 +15,7 @@ nk_scrollbar_behavior(nk_flags *state, struct nk_input *in,
|
||||||
{
|
{
|
||||||
nk_flags ws = 0;
|
nk_flags ws = 0;
|
||||||
int left_mouse_down;
|
int left_mouse_down;
|
||||||
|
int left_mouse_clicked;
|
||||||
int left_mouse_click_in_cursor;
|
int left_mouse_click_in_cursor;
|
||||||
float scroll_delta;
|
float scroll_delta;
|
||||||
|
|
||||||
|
@ -22,13 +23,14 @@ nk_scrollbar_behavior(nk_flags *state, struct nk_input *in,
|
||||||
if (!in) return scroll_offset;
|
if (!in) return scroll_offset;
|
||||||
|
|
||||||
left_mouse_down = in->mouse.buttons[NK_BUTTON_LEFT].down;
|
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,
|
left_mouse_click_in_cursor = nk_input_has_mouse_click_down_in_rect(in,
|
||||||
NK_BUTTON_LEFT, *cursor, nk_true);
|
NK_BUTTON_LEFT, *cursor, nk_true);
|
||||||
if (nk_input_is_mouse_hovering_rect(in, *scroll))
|
if (nk_input_is_mouse_hovering_rect(in, *scroll))
|
||||||
*state = NK_WIDGET_STATE_HOVERED;
|
*state = NK_WIDGET_STATE_HOVERED;
|
||||||
|
|
||||||
scroll_delta = (o == NK_VERTICAL) ? in->mouse.scroll_delta.y: in->mouse.scroll_delta.x;
|
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 */
|
/* update cursor by mouse dragging */
|
||||||
float pixel, delta;
|
float pixel, delta;
|
||||||
*state = NK_WIDGET_STATE_ACTIVE;
|
*state = NK_WIDGET_STATE_ACTIVE;
|
||||||
|
|
Loading…
Reference in New Issue