| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 21df504 commit f748b40
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -47,14 +47,82 @@ static PyObject *py_ue_swidget_bind_on_mouse_button_down(ue_PySWidget *self, PyO | |||
| 47 | 47 | UPythonSlateDelegate *py_delegate = NewObject<UPythonSlateDelegate>(); | |
| 48 | 48 | py_delegate->SetPyCallable(py_callable); | |
| 49 | 49 | py_delegate->AddToRoot(); | |
| 50 | - handler.BindUObject(py_delegate, &UPythonSlateDelegate::OnMouseButtonDown); | ||
| 50 | + handler.BindUObject(py_delegate, &UPythonSlateDelegate::OnMouseEvent); | ||
| 51 | 51 | ||
| 52 | 52 | self->s_widget->SetOnMouseButtonDown(handler); | |
| 53 | 53 | ||
| 54 | 54 | Py_INCREF(self); | |
| 55 | 55 | return (PyObject *)self; | |
| 56 | 56 | } | |
| 57 | 57 | ||
| 58 | + static PyObject *py_ue_swidget_bind_on_mouse_button_up(ue_PySWidget *self, PyObject * args) { | ||
| 59 | + PyObject *py_callable; | ||
| 60 | + if (!PyArg_ParseTuple(args, "O:bind_on_mouse_button_up", &py_callable)) { | ||
| 61 | + return NULL; | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + if (!PyCallable_Check(py_callable)) { | ||
| 65 | + return PyErr_Format(PyExc_Exception, "argument is not callable"); | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + FPointerEventHandler handler; | ||
| 69 | + UPythonSlateDelegate *py_delegate = NewObject<UPythonSlateDelegate>(); | ||
| 70 | + py_delegate->SetPyCallable(py_callable); | ||
| 71 | + py_delegate->AddToRoot(); | ||
| 72 | + handler.BindUObject(py_delegate, &UPythonSlateDelegate::OnMouseEvent); | ||
| 73 | + | ||
| 74 | + self->s_widget->SetOnMouseButtonUp(handler); | ||
| 75 | + | ||
| 76 | + Py_INCREF(self); | ||
| 77 | + return (PyObject *)self; | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + static PyObject *py_ue_swidget_bind_on_mouse_double_click(ue_PySWidget *self, PyObject * args) { | ||
| 81 | + PyObject *py_callable; | ||
| 82 | + if (!PyArg_ParseTuple(args, "O:bind_on_mouse_double_click", &py_callable)) { | ||
| 83 | + return NULL; | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + if (!PyCallable_Check(py_callable)) { | ||
| 87 | + return PyErr_Format(PyExc_Exception, "argument is not callable"); | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + FPointerEventHandler handler; | ||
| 91 | + UPythonSlateDelegate *py_delegate = NewObject<UPythonSlateDelegate>(); | ||
| 92 | + py_delegate->SetPyCallable(py_callable); | ||
| 93 | + py_delegate->AddToRoot(); | ||
| 94 | + handler.BindUObject(py_delegate, &UPythonSlateDelegate::OnMouseEvent); | ||
| 95 | + | ||
| 96 | + self->s_widget->SetOnMouseDoubleClick(handler); | ||
| 97 | + | ||
| 98 | + Py_INCREF(self); | ||
| 99 | + return (PyObject *)self; | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + static PyObject *py_ue_swidget_bind_on_mouse_move(ue_PySWidget *self, PyObject * args) { | ||
| 103 | + PyObject *py_callable; | ||
| 104 | + if (!PyArg_ParseTuple(args, "O:bind_on_mouse_move", &py_callable)) { | ||
| 105 | + return NULL; | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + if (!PyCallable_Check(py_callable)) { | ||
| 109 | + return PyErr_Format(PyExc_Exception, "argument is not callable"); | ||
| 110 | + } | ||
| 111 | + | ||
| 112 | + FPointerEventHandler handler; | ||
| 113 | + UPythonSlateDelegate *py_delegate = NewObject<UPythonSlateDelegate>(); | ||
| 114 | + py_delegate->SetPyCallable(py_callable); | ||
| 115 | + py_delegate->AddToRoot(); | ||
| 116 | + handler.BindUObject(py_delegate, &UPythonSlateDelegate::OnMouseEvent); | ||
| 117 | + | ||
| 118 | + self->s_widget->SetOnMouseMove(handler); | ||
| 119 | + | ||
| 120 | + Py_INCREF(self); | ||
| 121 | + return (PyObject *)self; | ||
| 122 | + } | ||
| 123 | + | ||
| 124 | + | ||
| 125 | + | ||
| 58 | 126 | static PyObject *py_ue_swidget_has_keyboard_focus(ue_PySWidget *self, PyObject * args) { | |
| 59 | 127 | ||
| 60 | 128 | if (self->s_widget->HasKeyboardFocus()) { | |
@@ -78,6 +146,9 @@ static PyMethodDef ue_PySWidget_methods[] = { | |||
| 78 | 146 | { "set_tooltip_text", (PyCFunction)py_ue_swidget_set_tooltip_text, METH_VARARGS, "" }, | |
| 79 | 147 | { "has_keyboard_focus", (PyCFunction)py_ue_swidget_has_keyboard_focus, METH_VARARGS, "" }, | |
| 80 | 148 | { "bind_on_mouse_button_down", (PyCFunction)py_ue_swidget_bind_on_mouse_button_down, METH_VARARGS, "" }, | |
| 149 | + { "bind_on_mouse_button_up", (PyCFunction)py_ue_swidget_bind_on_mouse_button_down, METH_VARARGS, "" }, | ||
| 150 | + { "bind_on_mouse_double_click", (PyCFunction)py_ue_swidget_bind_on_mouse_double_click, METH_VARARGS, "" }, | ||
| 151 | + { "bind_on_mouse_move", (PyCFunction)py_ue_swidget_bind_on_mouse_move, METH_VARARGS, "" }, | ||
| 81 | 152 | { NULL } /* Sentinel */ | |
| 82 | 153 | }; | |
| 83 | 154 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,11 +8,9 @@ | |||
| 8 | 8 | ||
| 9 | 9 | #include "UEPySlate.h" | |
| 10 | 10 | ||
| 11 | - FReply UPythonSlateDelegate::OnMouseButtonDown(const FGeometry &geometry, const FPointerEvent &pointer_event) { | ||
| 11 | + FReply UPythonSlateDelegate::OnMouseEvent(const FGeometry &geometry, const FPointerEvent &pointer_event) { | ||
| 12 | 12 | FScopePythonGIL gil; | |
| 13 | 13 | ||
| 14 | - UE_LOG(LogPython, Warning, TEXT("MOUSE BUTTON DOWN")); | ||
| 15 | - | ||
| 16 | 14 | PyObject *ret = PyObject_CallFunction(py_callable, (char *)"OO", py_ue_new_uscriptstruct(FGeometry::StaticStruct(), (uint8 *)&geometry), py_ue_new_uscriptstruct(FPointerEvent::StaticStruct(), (uint8 *)&pointer_event)); | |
| 17 | 15 | if (!ret) { | |
| 18 | 16 | unreal_engine_py_log_error(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -63,7 +63,7 @@ class UPythonSlateDelegate : public UPythonDelegate | |||
| 63 | 63 | GENERATED_BODY() | |
| 64 | 64 | ||
| 65 | 65 | public: | |
| 66 | - FReply OnMouseButtonDown(const FGeometry &geometry, const FPointerEvent &pointer_event); | ||
| 66 | + FReply OnMouseEvent(const FGeometry &geometry, const FPointerEvent &pointer_event); | ||
| 67 | 67 | FReply OnClicked(); | |
| 68 | 68 | }; | |
| 69 | 69 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments