diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-09-10 21:24:36 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-09-10 21:29:31 +0300 |
commit | 54daeb185ff914c38728721eea41ac96f9813d0f (patch) | |
tree | 4997fe7dd6f1708ad1c10bc321f61a54d42b3381 | |
parent | 477e81128d2fa0035d86690ce2a0027d31625769 (diff) |
PyAPI: add an update method for properties
This is called when modifying an RNA property,
however it can be useful to be able to make a properties
update callback run without having to change it.
-rw-r--r-- | source/blender/python/intern/bpy_rna.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 662572cba61..5414c4e4204 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -3389,6 +3389,21 @@ static PyObject *pyrna_prop_as_bytes(BPy_PropertyRNA *self) } } +PyDoc_STRVAR(pyrna_prop_update_doc, +".. method:: update()\n" +"\n" +" Execute the properties update callback.\n" +"\n" +" .. note::\n" +" This is called when assigning a property,\n" +" however in rare cases its useful to call explicitly.\n" +); +static PyObject *pyrna_prop_update(BPy_PropertyRNA *self) +{ + RNA_property_update(BPy_GetContext(), &self->ptr, self->prop); + Py_RETURN_NONE; +} + PyDoc_STRVAR(pyrna_struct_type_recast_doc, ".. method:: type_recast()\n" "\n" @@ -4722,6 +4737,7 @@ static struct PyMethodDef pyrna_struct_methods[] = { static struct PyMethodDef pyrna_prop_methods[] = { {"path_from_id", (PyCFunction)pyrna_prop_path_from_id, METH_NOARGS, pyrna_prop_path_from_id_doc}, {"as_bytes", (PyCFunction)pyrna_prop_as_bytes, METH_NOARGS, pyrna_prop_as_bytes_doc}, + {"update", (PyCFunction)pyrna_prop_update, METH_NOARGS, pyrna_prop_update_doc}, {"__dir__", (PyCFunction)pyrna_prop_dir, METH_NOARGS, NULL}, {NULL, NULL, 0, NULL} }; |