UI: Let object drop operator display hint why it's disabled
When dragging an object in non-object mode into a 3D View, there will now be red text explaining that this is only possible in object mode. The previous commit enabled this.
This commit is contained in:
parent
df2e053935
commit
7979dff9dc
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)) {
|
||||
|
|
Loading…
Reference in New Issue