From de3f6b3ec19d2402be8003e172c69e87c356f310 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 9 Oct 2013 14:35:25 +0000 Subject: [PATCH] re-enable activating the text input field for new popup dialog boxes, I'd disabled this for 2.68 since it caused bug [#36109]. This fix now only enabled text activation for popups. (so the toolbar textboxes are skipped) --- source/blender/editors/animation/anim_markers.c | 2 +- source/blender/editors/armature/pose_lib.c | 2 +- .../editors/interface/interface_layout.c | 15 ++++++++++----- source/blender/windowmanager/WM_api.h | 1 + .../blender/windowmanager/intern/wm_operators.c | 17 +++++++++++++---- 5 files changed, 26 insertions(+), 11 deletions(-) diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 3c8576be312..34246427b7e 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -1380,7 +1380,7 @@ static int ed_marker_rename_invoke_wrapper(bContext *C, wmOperator *op, const wm RNA_string_set(op->ptr, "name", marker->name); /* now see if the operator is usable */ - return ed_markers_opwrap_invoke_custom(C, op, event, WM_operator_props_popup); + return ed_markers_opwrap_invoke_custom(C, op, event, WM_operator_props_popup_confirm); } static void MARKER_OT_rename(wmOperatorType *ot) diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c index cb7a699b522..182f94b3693 100644 --- a/source/blender/editors/armature/pose_lib.c +++ b/source/blender/editors/armature/pose_lib.c @@ -638,7 +638,7 @@ static int poselib_rename_invoke(bContext *C, wmOperator *op, const wmEvent *eve } /* part to sync with other similar operators... */ - return WM_operator_props_popup(C, op, event); + return WM_operator_props_popup_confirm(C, op, event); } static int poselib_rename_exec(bContext *C, wmOperator *op) diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 424d2231a03..4e498476f5d 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -3091,20 +3091,25 @@ void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op, /* set various special settings for buttons */ { + uiBlock *block = uiLayoutGetBlock(layout); + const bool is_popup = (block->flag & UI_BLOCK_KEEP_OPEN) != 0; uiBut *but; + - for (but = uiLayoutGetBlock(layout)->buttons.first; but; but = but->next) { + for (but = block->buttons.first; but; but = but->next) { /* no undo for buttons for operator redo panels */ uiButClearFlag(but, UI_BUT_UNDO); -#if 0 /* broken, causes freedback loop, see [#36109] */ + /* only for popups, see [#36109] */ + /* if button is operator's default property, and a text-field, enable focus for it * - this is used for allowing operators with popups to rename stuff with fewer clicks */ - if ((but->rnaprop == op->type->prop) && (but->type == TEX)) { - uiButSetFocusOnEnter(CTX_wm_window(C), but); + if (is_popup) { + if ((but->rnaprop == op->type->prop) && (but->type == TEX)) { + uiButSetFocusOnEnter(CTX_wm_window(C), but); + } } -#endif } } } diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 84b376edcd8..c338d49fe17 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -198,6 +198,7 @@ bool WM_operator_filesel_ensure_ext_imtype(wmOperator *op, const struct I /* poll callback, context checks */ int WM_operator_winactive (struct bContext *C); /* invoke callback, exec + redo popup */ +int WM_operator_props_popup_confirm(struct bContext *C, struct wmOperator *op, const struct wmEvent *event); int WM_operator_props_popup_call(struct bContext *C, struct wmOperator *op, const struct wmEvent *event); int WM_operator_props_popup (struct bContext *C, struct wmOperator *op, const struct wmEvent *event); int WM_operator_props_dialog_popup(struct bContext *C, struct wmOperator *op, int width, int height); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 5e1e5890c6b..17c7d915b64 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1433,7 +1433,8 @@ int WM_operator_ui_popup(bContext *C, wmOperator *op, int width, int height) * For use by #WM_operator_props_popup_call, #WM_operator_props_popup only. * * \note operator menu needs undo flag enabled , for redo callback */ -static int wm_operator_props_popup_ex(bContext *C, wmOperator *op, const int do_call) +static int wm_operator_props_popup_ex(bContext *C, wmOperator *op, + const bool do_call, const bool do_redo) { if ((op->type->flag & OPTYPE_REGISTER) == 0) { BKE_reportf(op->reports, RPT_ERROR, @@ -1443,7 +1444,7 @@ static int wm_operator_props_popup_ex(bContext *C, wmOperator *op, const int do_ /* if we don't have global undo, we can't do undo push for automatic redo, * so we require manual OK clicking in this popup */ - if (!(U.uiflag & USER_GLOBALUNDO)) + if (!do_redo || !(U.uiflag & USER_GLOBALUNDO)) return WM_operator_props_dialog_popup(C, op, 15 * UI_UNIT_X, UI_UNIT_Y); uiPupBlockEx(C, wm_block_create_redo, NULL, wm_block_redo_cancel_cb, op); @@ -1454,18 +1455,26 @@ static int wm_operator_props_popup_ex(bContext *C, wmOperator *op, const int do_ return OPERATOR_RUNNING_MODAL; } +/* Same as WM_operator_props_popup but don't use operator redo. + * just wraps WM_operator_props_dialog_popup. + */ +int WM_operator_props_popup_confirm(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +{ + return wm_operator_props_popup_ex(C, op, false, false); +} + /* Same as WM_operator_props_popup but call the operator first, * This way - the button values correspond to the result of the operator. * Without this, first access to a button will make the result jump, * see [#32452] */ int WM_operator_props_popup_call(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { - return wm_operator_props_popup_ex(C, op, TRUE); + return wm_operator_props_popup_ex(C, op, true, true); } int WM_operator_props_popup(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { - return wm_operator_props_popup_ex(C, op, FALSE); + return wm_operator_props_popup_ex(C, op, false, true); } int WM_operator_props_dialog_popup(bContext *C, wmOperator *op, int width, int height)