Don't close type manager when using the enum search feature while adding a new type

Also reduce the attribute name a bit
This commit is contained in:
Gorgious56
2025-01-14 08:44:21 +01:00
parent 595a3b3f87
commit ac2e69bd66
3 changed files with 9 additions and 9 deletions
+2 -2
View File
@@ -272,7 +272,7 @@ def prop_with_search(
layout: bpy.types.UILayout, layout: bpy.types.UILayout,
data: ENUM_ITEMS_DATA, data: ENUM_ITEMS_DATA,
prop_name: str, prop_name: str,
should_click_ok_to_validate: bool = False, should_click_ok: bool = False,
original_operator_path: Optional[str] = None, original_operator_path: Optional[str] = None,
**kwargs: Any, **kwargs: Any,
): ):
@@ -285,7 +285,7 @@ def prop_with_search(
row.context_pointer_set(name="data", data=data) row.context_pointer_set(name="data", data=data)
op = row.operator("bim.enum_property_search", text="", icon="VIEWZOOM") op = row.operator("bim.enum_property_search", text="", icon="VIEWZOOM")
op.prop_name = prop_name op.prop_name = prop_name
op.should_click_ok_to_validate = should_click_ok_to_validate op.should_click_ok = should_click_ok
op.original_operator_path = original_operator_path or "" op.original_operator_path = original_operator_path or ""
except TypeError: # Prop is not iterable except TypeError: # Prop is not iterable
pass pass
@@ -556,15 +556,15 @@ class AddElement(bpy.types.Operator, tool.Ifc.Operator):
props = context.scene.BIMRootProperties props = context.scene.BIMRootProperties
self.layout.use_property_split = True self.layout.use_property_split = True
self.layout.use_property_decorate = False self.layout.use_property_decorate = False
prop_with_search(self.layout, props, "ifc_product", text="Definition") prop_with_search(self.layout, props, "ifc_product", text="Definition", should_click_ok=True)
prop_with_search(self.layout, props, "ifc_class", should_click_ok_to_validate=True) prop_with_search(self.layout, props, "ifc_class", should_click_ok=True)
ifc_predefined_types = root_prop.get_ifc_predefined_types(context.scene.BIMRootProperties, context) ifc_predefined_types = root_prop.get_ifc_predefined_types(context.scene.BIMRootProperties, context)
if ifc_predefined_types: if ifc_predefined_types:
prop_with_search(self.layout, props, "ifc_predefined_type") prop_with_search(self.layout, props, "ifc_predefined_type", should_click_ok=True)
if props.ifc_predefined_type == "USERDEFINED": if props.ifc_predefined_type == "USERDEFINED":
row = self.layout.row() row = self.layout.row()
row.prop(props, "ifc_userdefined_type") row.prop(props, "ifc_userdefined_type")
prop_with_search(self.layout, props, "representation_template", text="Representation") prop_with_search(self.layout, props, "representation_template", text="Representation", should_click_ok=True)
if props.representation_template == "OBJ": if props.representation_template == "OBJ":
row = self.layout.row() row = self.layout.row()
row.prop(props, "representation_obj", text="Object") row.prop(props, "representation_obj", text="Object")
@@ -572,7 +572,7 @@ class AddElement(bpy.types.Operator, tool.Ifc.Operator):
row = self.layout.row() row = self.layout.row()
row.prop(props, "profile", text="Profile") row.prop(props, "profile", text="Profile")
if props.representation_template != "EMPTY": if props.representation_template != "EMPTY":
prop_with_search(self.layout, props, "contexts") prop_with_search(self.layout, props, "contexts", should_click_ok=True)
class LaunchAddElement(bpy.types.Operator, tool.Ifc.Operator): class LaunchAddElement(bpy.types.Operator, tool.Ifc.Operator):
+2 -2
View File
@@ -868,7 +868,7 @@ def update_enum_property_search_prop(self, context):
if self.first_launch: if self.first_launch:
self.first_launch = False self.first_launch = False
else: else:
if not self.should_click_ok_to_validate: if not self.should_click_ok:
context.window.screen = context.window.screen context.window.screen = context.window.screen
if predefined_type: if predefined_type:
try: try:
@@ -889,7 +889,7 @@ class BIM_OT_enum_property_search(bpy.types.Operator):
collection_identifiers: bpy.props.CollectionProperty(type=StrProperty) collection_identifiers: bpy.props.CollectionProperty(type=StrProperty)
collection_predefined_types: bpy.props.CollectionProperty(type=StrProperty) collection_predefined_types: bpy.props.CollectionProperty(type=StrProperty)
prop_name: bpy.props.StringProperty() prop_name: bpy.props.StringProperty()
should_click_ok_to_validate: bpy.props.BoolProperty(default=False) should_click_ok: bpy.props.BoolProperty(default=False)
original_operator_path: bpy.props.StringProperty(name="Original Operator Path", default="", options={"SKIP_SAVE"}) original_operator_path: bpy.props.StringProperty(name="Original Operator Path", default="", options={"SKIP_SAVE"})
identifiers: list[str] identifiers: list[str]