@@ -63,6 +63,32 @@ static PyObject *py_ue_fmenu_builder_add_menu_entry(ue_PyFMenuBuilder *self, PyO
6363 Py_RETURN_NONE;
6464}
6565
66+ static PyObject *py_ue_fmenu_builder_add_sub_menu (ue_PyFMenuBuilder *self, PyObject * args)
67+ {
68+ char *label;
69+ char *tooltip;
70+ PyObject *py_callable;
71+ PyObject *py_bool = nullptr ;
72+ if (!PyArg_ParseTuple (args, " ssO|O:add_sub_menu" , &label, &tooltip, &py_callable, &py_bool))
73+ return nullptr ;
74+
75+ if (!PyCallable_Check (py_callable))
76+ {
77+ return PyErr_Format (PyExc_Exception, " argument is not callable" );
78+ }
79+
80+
81+ TSharedRef<FPythonSlateDelegate> py_delegate = FUnrealEnginePythonHouseKeeper::Get ()->NewStaticSlateDelegate (py_callable);
82+
83+ FNewMenuDelegate menu_delegate;
84+ menu_delegate.BindSP (py_delegate, &FPythonSlateDelegate::SubMenuPyBuilder);
85+
86+
87+ self->menu_builder .AddSubMenu (FText::FromString (UTF8_TO_TCHAR (label)), FText::FromString (UTF8_TO_TCHAR (tooltip)), menu_delegate, (py_bool && PyObject_IsTrue (py_bool)) ? true : false );
88+
89+ Py_RETURN_NONE;
90+ }
91+
6692static PyObject *py_ue_fmenu_builder_add_menu_separator (ue_PyFMenuBuilder *self, PyObject * args)
6793{
6894 char *name = nullptr ;
@@ -130,6 +156,7 @@ static PyMethodDef ue_PyFMenuBuilder_methods[] = {
130156 { " add_menu_entry" , (PyCFunction)py_ue_fmenu_builder_add_menu_entry, METH_VARARGS, " " },
131157 { " add_menu_separator" , (PyCFunction)py_ue_fmenu_builder_add_menu_separator, METH_VARARGS, " " },
132158 { " add_search_widget" , (PyCFunction)py_ue_fmenu_builder_add_search_widget, METH_VARARGS, " " },
159+ { " add_sub_menu" , (PyCFunction)py_ue_fmenu_builder_add_sub_menu, METH_VARARGS, " " },
133160#if WITH_EDITOR
134161 { " add_asset_actions" , (PyCFunction)py_ue_fmenu_builder_add_asset_actions, METH_VARARGS, " " },
135162#endif
0 commit comments