diff options
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 1 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 13 |
2 files changed, 14 insertions, 0 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index e40026880c4..96ed179c8f4 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -230,6 +230,7 @@ void WM_operator_view3d_unit_defaults(struct bContext *C, struct wmOperator *op int WM_operator_smooth_viewtx_get(const struct wmOperator *op); int WM_menu_invoke_ex(struct bContext *C, struct wmOperator *op, int opcontext); int WM_menu_invoke (struct bContext *C, struct wmOperator *op, const struct wmEvent *event); +void WM_menu_name_call(struct bContext *C, const char *menu_name, short context); 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); diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index a71202bfa71..8f0b5de0cde 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -1394,6 +1394,19 @@ int WM_operator_name_call(bContext *C, const char *opstring, short context, Poin } /** + * Call an existent menu. The menu can be created in C or Python. + */ +void WM_menu_name_call(bContext *C, const char *menu_name, short context) +{ + wmOperatorType *ot = WM_operatortype_find("WM_OT_call_menu", false); + PointerRNA ptr; + WM_operator_properties_create_ptr(&ptr, ot); + RNA_string_set(&ptr, "name", menu_name); + WM_operator_name_call_ptr(C, ot, context, &ptr); + WM_operator_properties_free(&ptr); +} + +/** * Similar to #WM_operator_name_call called with #WM_OP_EXEC_DEFAULT context. * * - #wmOperatorType is used instead of operator name since python already has the operator type. |