From a52c904c7b2011d83dcebeb0c2eb16dfb664bd3a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 10 Aug 2023 15:46:21 +1000 Subject: [PATCH] Fix annotation tool getting "stuck" with IC-Keymap The annotation tool only exited on LMB or RMB mouse buttons, now check for all mouse buttons with special behavior with RMB. --- .../editors/gpencil_legacy/annotate_paint.cc | 17 ++++++++--------- .../editors/gpencil_legacy/gpencil_paint.cc | 16 ++++++++-------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/source/blender/editors/gpencil_legacy/annotate_paint.cc b/source/blender/editors/gpencil_legacy/annotate_paint.cc index 126109a16ac..168ac9acd19 100644 --- a/source/blender/editors/gpencil_legacy/annotate_paint.cc +++ b/source/blender/editors/gpencil_legacy/annotate_paint.cc @@ -2538,14 +2538,13 @@ static int annotation_draw_modal(bContext *C, wmOperator *op, const wmEvent *eve estate = OPERATOR_FINISHED; } - /* toggle painting mode upon mouse-button movement - * - LEFTMOUSE = standard drawing (all) / straight line drawing (all) / polyline (toolbox - * only) - * - RIGHTMOUSE = polyline (hotkey) / eraser (all) - * (Disabling RIGHTMOUSE case here results in bugs like #32647) - * also making sure we have a valid event value, to not exit too early - */ - if (ELEM(event->type, LEFTMOUSE, RIGHTMOUSE) && ELEM(event->val, KM_PRESS, KM_RELEASE)) { + /* Toggle painting mode upon mouse-button movement + * - #RIGHTMOUSE: eraser (all). + * (Disabling #RIGHTMOUSE case here results in bugs like #32647) + * - Others (typically LMB): standard drawing (all) / straight line drawing (all). + * Also making sure we have a valid event value, to not exit too early. */ + + if (ISMOUSE_BUTTON(event->type) && ELEM(event->val, KM_PRESS, KM_RELEASE)) { /* if painting, end stroke */ if (p->status == GP_STATUS_PAINTING) { int sketch = 0; @@ -2634,7 +2633,7 @@ static int annotation_draw_modal(bContext *C, wmOperator *op, const wmEvent *eve /* turn on eraser */ p->paintmode = GP_PAINTMODE_ERASER; } - else if (event->type == LEFTMOUSE) { + else { /* Any mouse button besides right. */ /* restore drawmode to default */ p->paintmode = eGPencil_PaintModes(RNA_enum_get(op->ptr, "mode")); } diff --git a/source/blender/editors/gpencil_legacy/gpencil_paint.cc b/source/blender/editors/gpencil_legacy/gpencil_paint.cc index 82327798e46..2fc9c04eb4f 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_paint.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_paint.cc @@ -3776,13 +3776,13 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) estate = OPERATOR_FINISHED; } - /* toggle painting mode upon mouse-button movement - * - LEFTMOUSE = standard drawing (all) / straight line drawing (all) - * - RIGHTMOUSE = eraser (all) - * (Disabling RIGHTMOUSE case here results in bugs like #32647) - * also making sure we have a valid event value, to not exit too early - */ - if (ELEM(event->type, LEFTMOUSE, RIGHTMOUSE) && ELEM(event->val, KM_PRESS, KM_RELEASE)) { + /* Toggle painting mode upon mouse-button movement + * - #RIGHTMOUSE: eraser (all). + * (Disabling #RIGHTMOUSE case here results in bugs like #32647) + * - Others (typically LMB): standard drawing (all) / straight line drawing (all). + * Also making sure we have a valid event value, to not exit too early. */ + + if (ISMOUSE_BUTTON(event->type) && ELEM(event->val, KM_PRESS, KM_RELEASE)) { /* if painting, end stroke */ if (p->status == GP_STATUS_PAINTING) { p->status = GP_STATUS_DONE; @@ -3831,7 +3831,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) /* turn on eraser */ p->paintmode = GP_PAINTMODE_ERASER; } - else if (event->type == LEFTMOUSE) { + else { /* Any mouse button besides the right. */ /* restore drawmode to default */ p->paintmode = eGPencil_PaintModes(RNA_enum_get(op->ptr, "mode")); }