From a8abc8e379498e9c3981eab4180ba0b78dc0bd2e Mon Sep 17 00:00:00 2001 From: Gorgious56 Date: Fri, 20 Sep 2024 09:53:00 +0200 Subject: [PATCH] Fix #5333 : Searching for the class name using the looking glass button doesn't close the type manager anymore. --- src/bonsai/bonsai/bim/helper.py | 3 ++- src/bonsai/bonsai/bim/operator.py | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/bonsai/bonsai/bim/helper.py b/src/bonsai/bonsai/bim/helper.py index 298e7cc58d..9363a69f78 100644 --- a/src/bonsai/bonsai/bim/helper.py +++ b/src/bonsai/bonsai/bim/helper.py @@ -199,7 +199,7 @@ def export_attributes(props, callback: Optional[Callable] = None) -> dict[str, A return attributes -def prop_with_search(layout, data, prop_name, **kwargs): +def prop_with_search(layout, data, prop_name, should_click_ok_to_validate=False, **kwargs): # kwargs are layout.prop arguments (text, icon, etc.) row = layout.row(align=True) row.prop(data, prop_name, **kwargs) @@ -209,6 +209,7 @@ def prop_with_search(layout, data, prop_name, **kwargs): row.context_pointer_set(name="data", data=data) op = row.operator("bim.enum_property_search", text="", icon="VIEWZOOM") op.prop_name = prop_name + op.should_click_ok_to_validate = should_click_ok_to_validate except TypeError: # Prop is not iterable pass diff --git a/src/bonsai/bonsai/bim/operator.py b/src/bonsai/bonsai/bim/operator.py index 9e04908e4e..f101b06d5a 100644 --- a/src/bonsai/bonsai/bim/operator.py +++ b/src/bonsai/bonsai/bim/operator.py @@ -868,7 +868,8 @@ def update_enum_property_search_prop(self, context): if self.first_launch: self.first_launch = False else: - context.window.screen = context.window.screen + if not self.should_click_ok_to_validate: + context.window.screen = context.window.screen if predefined_type: try: setattr(context.data, "ifc_predefined_type", predefined_type) @@ -888,6 +889,7 @@ class BIM_OT_enum_property_search(bpy.types.Operator): collection_identifiers: bpy.props.CollectionProperty(type=StrProperty) collection_predefined_types: bpy.props.CollectionProperty(type=StrProperty) prop_name: bpy.props.StringProperty() + should_click_ok_to_validate: bpy.props.BoolProperty(default=False) def invoke(self, context, event): self.clear_collections()