fix [#31382] Loop Cut and Slide numpad (-)
authorCampbell Barton <ideasman42@gmail.com>
Thu, 10 May 2012 07:10:39 +0000 (07:10 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 10 May 2012 07:10:39 +0000 (07:10 +0000)
investigation lead to finding 3 bugs here...
- transform key input handling didnt ignore minus key on an unsigned value as it should.
- not being able to set numcuts to 0 made typing in numbers not very useful.
- backspace would set the cuts to an unsigned value.

source/blender/editors/mesh/editmesh_loopcut.c
source/blender/editors/util/numinput.c

index 0b65cce20d7186b5eddd10a3c9d5d5332163e9f3..7298153791efe8ebb7ea95d776319595246268ac 100644 (file)
@@ -492,7 +492,7 @@ static int loopcut_modal(bContext *C, wmOperator *op, wmEvent *event)
                        if (event->val == KM_RELEASE)
                                break;
 
-                       cuts = MAX2(cuts - 1, 1);
+                       cuts = MAX2(cuts - 1, 0);
                        RNA_int_set(op->ptr, "number_cuts", cuts);
                        ringsel_find_edge(lcd, cuts);
                        show_cuts = TRUE;
@@ -519,12 +519,15 @@ static int loopcut_modal(bContext *C, wmOperator *op, wmEvent *event)
        
        /* using the keyboard to input the number of cuts */
        if (event->val == KM_PRESS) {
-               float value;
+               /* init as zero so backspace clears */
+               float value = 0.0f;
                
                if (handleNumInput(&lcd->num, event)) {
                        applyNumInput(&lcd->num, &value);
                        
-                       cuts = CLAMPIS(value, 1, 130);
+                       /* allow zero so you can backspace and type in a value
+                        * otherwise 1 as minimum would make more sense */
+                       cuts = CLAMPIS(value, 0, 130);
                        
                        RNA_int_set(op->ptr, "number_cuts", cuts);
                        ringsel_find_edge(lcd, cuts);
index 1f1d5a0c0c083e8800ad86c891dd7ee86bc1230d..912908296626791c75445bb3764a2ab0c829ebca 100644 (file)
@@ -221,7 +221,7 @@ char handleNumInput(NumInput *n, wmEvent *event)
                                        break;
                        case MINUSKEY:
                                if (n->flag & NUM_NO_NEGATIVE)
-                                       break;
+                                       return 0;
 
                                if (n->ctrl[idx]) {
                                        n->ctrl[idx] *= -1;