diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-01-30 01:34:58 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-01-30 01:34:58 +0400 |
commit | 8e740e9797baaf9ca41ed38a47915b4b62c5004a (patch) | |
tree | 095b999cb1d4cbe029c49a86da0a0d75171b415c /release | |
parent | f02f491ed04b3427840c375de3fd62c9de59cd84 (diff) |
Fix #34016: add backwards compatibility for deprecated region.callback_add
python function, this keep addons working. It's better to use the new function
but might as well avoid breaking compatibility here.
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/modules/bpy_types.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index 9161cc20d2c..b0a4e05b107 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -737,3 +737,21 @@ class Menu(StructRNA, _GenericUI, metaclass=RNAMeta): self.path_menu(bpy.utils.preset_paths(self.preset_subdir), self.preset_operator, filter_ext=lambda ext: ext.lower() in {".py", ".xml"}) + +class Region(StructRNA): + __slots__ = () + + def callback_add(self, cb, args, draw_mode): + """ + Append a draw function to this region, + deprecated, instead use bpy.types.SpaceView3D.draw_handler_add + """ + for area in self.id_data.areas: + for region in area.regions: + if region == self: + spacetype = type(area.spaces[0]) + return spacetype.draw_handler_add(cb, args, self.type, + draw_mode) + + return None + |