@@ -108,6 +108,27 @@ static PyObject *py_ue_swindow_add_modal(ue_PySWindow *self, PyObject * args)
108108}
109109#endif
110110
111+ static PyObject *py_ue_swindow_add_child (ue_PySWindow *self, PyObject * args)
112+ {
113+ PyObject *py_obj;
114+ if (!PyArg_ParseTuple (args, " O:add_child" , &py_obj))
115+ {
116+ return NULL ;
117+ }
118+
119+ ue_PySWindow *py_swindow_child = py_ue_is_swindow (py_obj);
120+ if (!py_swindow_child)
121+ {
122+ return PyErr_Format (PyExc_Exception, " argument is not a SWindow" );
123+ }
124+
125+ FSlateApplication::Get ().AddWindowAsNativeChild (
126+ StaticCastSharedRef<SWindow>(py_swindow_child->s_compound_widget .s_widget .s_widget ),
127+ sw_window);
128+
129+ Py_RETURN_NONE;
130+ }
131+
111132static PyMethodDef ue_PySWindow_methods[] = {
112133 { " set_title" , (PyCFunction)py_ue_swindow_set_title, METH_VARARGS, " " },
113134 { " set_sizing_rule" , (PyCFunction)py_ue_swindow_set_sizing_rule, METH_VARARGS, " " },
@@ -119,6 +140,7 @@ static PyMethodDef ue_PySWindow_methods[] = {
119140#if WITH_EDITOR
120141 { " add_modal" , (PyCFunction)py_ue_swindow_add_modal, METH_VARARGS, " " },
121142#endif
143+ { " add_child" , (PyCFunction)py_ue_swindow_add_child, METH_VARARGS, " " },
122144 { NULL } /* Sentinel */
123145};
124146
@@ -222,7 +244,12 @@ static int ue_py_swindow_init(ue_PySWindow *self, PyObject *args, PyObject *kwar
222244 sw_window->SetOnWindowClosed (handler);
223245 }
224246
225- FSlateApplication::Get ().AddWindow (StaticCastSharedRef<SWindow>(sw_window->AsShared ()), true );
247+ // is it a child ?
248+ PyObject *is_child = ue_py_dict_get_item (kwargs, " child" );
249+ if (!(is_child && PyObject_IsTrue (is_child)))
250+ {
251+ FSlateApplication::Get ().AddWindow (StaticCastSharedRef<SWindow>(sw_window->AsShared ()), true );
252+ }
226253
227254 return 0 ;
228255}
@@ -241,3 +268,10 @@ void ue_python_init_swindow(PyObject *ue_module)
241268 Py_INCREF (&ue_PySWindowType);
242269 PyModule_AddObject (ue_module, " SWindow" , (PyObject *)&ue_PySWindowType);
243270}
271+
272+ ue_PySWindow *py_ue_is_swindow (PyObject *obj)
273+ {
274+ if (!PyObject_IsInstance (obj, (PyObject *)&ue_PySWindowType))
275+ return nullptr ;
276+ return (ue_PySWindow *)obj;
277+ }
0 commit comments