Keymap: only use delete confirmation for X-key

Only use confirmation w/ X-key since this is more likely to be pressed
by accident. Delete-key delete doesn't confirm.

Part of D3953 by @Zachman w/ edits
This commit is contained in:
Campbell Barton 2018-11-20 10:06:02 +11:00
parent 750690ae7a
commit 47139c69d7
5 changed files with 28 additions and 4 deletions

View File

@ -3245,9 +3245,9 @@ def km_object_mode(params):
("object.delete", {"type": 'X', "value": 'PRESS', "shift": True},
{"properties": [("use_global", True)]}),
("object.delete", {"type": 'DEL', "value": 'PRESS'},
{"properties": [("use_global", False)]}),
{"properties": [("use_global", False), ("confirm", False)]}),
("object.delete", {"type": 'DEL', "value": 'PRESS', "shift": True},
{"properties": [("use_global", True)]}),
{"properties": [("use_global", True), ("confirm", False)]}),
op_menu("VIEW3D_MT_add", {"type": 'A', "value": 'PRESS', "shift": True}),
op_menu("VIEW3D_MT_object_apply", {"type": 'A', "value": 'PRESS', "ctrl": True}),
op_menu("VIEW3D_MT_make_links", {"type": 'L', "value": 'PRESS', "ctrl": True}),

View File

@ -1410,7 +1410,7 @@ void OBJECT_OT_delete(wmOperatorType *ot)
ot->idname = "OBJECT_OT_delete";
/* api callbacks */
ot->invoke = WM_operator_confirm;
ot->invoke = WM_operator_confirm_or_exec;
ot->exec = object_delete_exec;
ot->poll = ED_operator_objectmode;
@ -1420,6 +1420,7 @@ void OBJECT_OT_delete(wmOperatorType *ot)
PropertyRNA *prop;
prop = RNA_def_boolean(ot->srna, "use_global", 0, "Delete Globally", "Remove object from all scenes");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
WM_operator_properties_confirm_or_exec(ot);
}
/**************************** Copy Utilities ******************************/

View File

@ -287,7 +287,8 @@ void WM_menu_name_call(struct bContext *C, const char *menu_name, short context
int WM_enum_search_invoke_previews(struct bContext *C, struct wmOperator *op, short prv_cols, short prv_rows);
int WM_enum_search_invoke(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
/* invoke callback, confirm menu + exec */
int WM_operator_confirm (struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
int WM_operator_confirm(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
int WM_operator_confirm_or_exec(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
/* invoke callback, file selector "filepath" unset + exec */
int WM_operator_filesel (struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
bool WM_operator_filesel_ensure_ext_imtype(wmOperator *op, const struct ImageFormatData *im_format);
@ -348,6 +349,7 @@ bool WM_operator_last_properties_store(struct wmOperator *op);
/* wm_operator_props.c */
void WM_operator_properties_confirm_or_exec(struct wmOperatorType *ot);
void WM_operator_properties_filesel(
struct wmOperatorType *ot, int filter, short type, short action,
short flag, short display, short sort);

View File

@ -44,6 +44,15 @@
#include "WM_api.h"
#include "WM_types.h"
void WM_operator_properties_confirm_or_exec(wmOperatorType *ot)
{
PropertyRNA *prop;
prop = RNA_def_boolean(ot->srna, "confirm", true, "Confirm", "Prompt for confirmation");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
}
/* default properties for fileselect */
void WM_operator_properties_filesel(
wmOperatorType *ot, int filter, short type, short action,

View File

@ -863,6 +863,18 @@ int WM_operator_confirm(bContext *C, wmOperator *op, const wmEvent *UNUSED(event
return WM_operator_confirm_message(C, op, NULL);
}
int WM_operator_confirm_or_exec(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
const bool confirm = RNA_boolean_get(op->ptr, "confirm");
if (confirm) {
return WM_operator_confirm_message(C, op, NULL);
}
else {
return op->type->exec(C, op);
}
}
/* op->invoke, opens fileselect if path property not set, otherwise executes */
int WM_operator_filesel(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{