WM: check for release instead of not pressed
authorCampbell Barton <ideasman42@gmail.com>
Thu, 7 Jun 2018 14:19:59 +0000 (16:19 +0200)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 7 Jun 2018 14:19:59 +0000 (16:19 +0200)
Makes reasoning about events more predictable.

source/blender/editors/interface/interface_handlers.c

index 590b34dfc219b8704cb0264fe143971509220e3f..3abaa1d88ebb75984b235d7b51727a88b97bf0f3 100644 (file)
@@ -1364,7 +1364,7 @@ static int ui_handler_region_drag_toggle(bContext *C, const wmEvent *event, void
        switch (event->type) {
                case LEFTMOUSE:
                {
-                       if (event->val != KM_PRESS) {
+                       if (event->val == KM_RELEASE) {
                                done = true;
                        }
                        break;
@@ -3776,7 +3776,7 @@ static int ui_do_but_BUT(
                }
        }
        else if (data->state == BUTTON_STATE_WAIT_RELEASE) {
-               if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
+               if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
                        if (!(but->flag & UI_SELECT))
                                data->cancel = true;
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
@@ -4400,7 +4400,7 @@ static int ui_do_but_NUM(
                                button_activate_state(C, but, BUTTON_STATE_EXIT);
                        }
                }
-               else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
+               else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
                        if (data->dragchange) {
 #ifdef USE_DRAG_MULTINUM
                                /* if we started multibutton but didnt drag, then edit */
@@ -4711,7 +4711,7 @@ static int ui_do_but_SLI(
                                button_activate_state(C, but, BUTTON_STATE_EXIT);
                        }
                }
-               else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
+               else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
                        if (data->dragchange) {
 #ifdef USE_DRAG_MULTINUM
                                /* if we started multibutton but didnt drag, then edit */
@@ -4864,7 +4864,7 @@ static int ui_do_but_SCROLL(
                                button_activate_state(C, but, BUTTON_STATE_EXIT);
                        }
                }
-               else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
+               else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                }
                else if (event->type == MOUSEMOVE) {
@@ -4916,7 +4916,7 @@ static int ui_do_but_GRIP(
                                button_activate_state(C, but, BUTTON_STATE_EXIT);
                        }
                }
-               else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
+               else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                }
                else if (event->type == MOUSEMOVE) {
@@ -5301,7 +5301,7 @@ static int ui_do_but_UNITVEC(
                                        ui_numedit_apply(C, block, but, data);
                        }
                }
-               else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
+               else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                }
 
@@ -5635,7 +5635,7 @@ static int ui_do_but_HSVCUBE(
                                        ui_numedit_apply(C, block, but, data);
                        }
                }
-               else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
+               else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                }
 
@@ -5913,7 +5913,7 @@ static int ui_do_but_HSVCIRCLE(
                                }
                        }
                }
-               else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
+               else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                }
                return WM_UI_HANDLER_BREAK;
@@ -6003,7 +6003,7 @@ static int ui_do_but_COLORBAND(
                                        ui_numedit_apply(C, block, but, data);
                        }
                }
-               else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
+               else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                }
                else if (ELEM(event->type, ESCKEY, RIGHTMOUSE)) {
@@ -6253,7 +6253,7 @@ static int ui_do_but_CURVE(
                                        ui_numedit_apply(C, block, but, data);
                        }
                }
-               else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
+               else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
                        if (data->dragsel != -1) {
                                CurveMapping *cumap = (CurveMapping *)but->poin;
                                CurveMap *cuma = cumap->cm + cumap->cur;
@@ -6351,7 +6351,7 @@ static int ui_do_but_HISTOGRAM(
                                        ui_numedit_apply(C, block, but, data);
                        }
                }
-               else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
+               else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                }
                return WM_UI_HANDLER_BREAK;
@@ -6426,7 +6426,7 @@ static int ui_do_but_WAVEFORM(
                                        ui_numedit_apply(C, block, but, data);
                        }
                }
-               else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
+               else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                }
                return WM_UI_HANDLER_BREAK;
@@ -6453,7 +6453,7 @@ static int ui_do_but_LINK(
        }
        else if (data->state == BUTTON_STATE_WAIT_RELEASE) {
 
-               if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
+               if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
                        if (!(but->flag & UI_SELECT))
                                data->cancel = true;
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
@@ -6539,7 +6539,7 @@ static int ui_do_but_TRACKPREVIEW(
                                        ui_numedit_apply(C, block, but, data);
                        }
                }
-               else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
+               else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                }
                return WM_UI_HANDLER_BREAK;