Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/editors/include/ED_screen.h1
-rw-r--r--source/blender/editors/object/object_add.c2
-rw-r--r--source/blender/editors/screen/screen_ops.c14
3 files changed, 16 insertions, 1 deletions
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h
index b90c7f27c57..08b6c02a8d0 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -317,6 +317,7 @@ bool ED_operator_regionactive(struct bContext *C);
bool ED_operator_scene(struct bContext *C);
bool ED_operator_scene_editable(struct bContext *C);
bool ED_operator_objectmode(struct bContext *C);
+bool ED_operator_objectmode_poll_msg(struct bContext *C);
bool ED_operator_view3d_active(struct bContext *C);
bool ED_operator_region_view3d_active(struct bContext *C);
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 58767d5f50f..917df0da868 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -3591,7 +3591,7 @@ void OBJECT_OT_add_named(wmOperatorType *ot)
/* api callbacks */
ot->invoke = object_add_drop_xy_generic_invoke;
ot->exec = object_add_named_exec;
- ot->poll = ED_operator_objectmode;
+ ot->poll = ED_operator_objectmode_poll_msg;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 5acfc5ac681..fc1b0ed173e 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -219,6 +219,20 @@ bool ED_operator_objectmode(bContext *C)
return true;
}
+/**
+ * Same as #ED_operator_objectmode() but additionally sets a "disabled hint". That is, a message
+ * to be displayed to the user explaining why the operator can't be used in current context.
+ */
+bool ED_operator_objectmode_poll_msg(bContext *C)
+{
+ if (!ED_operator_objectmode(C)) {
+ CTX_wm_operator_poll_msg_set(C, "Only supported in object mode");
+ return false;
+ }
+
+ return true;
+}
+
static bool ed_spacetype_test(bContext *C, int type)
{
if (ED_operator_areaactive(C)) {