Clicking on an entry in the search field popup automatically validates and closes the popup

No need to click on "OK" anymore.
This is not a hacky workaround using the mouse position, it uses a signal sent to Blender to close the active popup
See https://blenderartists.org/t/programatically-close-pie-menu-2-79/1488807/2
re-committing since it seems I commited to the wrong branch last week
This commit is contained in:
Gorgious56
2023-10-30 14:19:01 +01:00
parent d8ff83da73
commit 4e1daea838
@@ -816,6 +816,10 @@ def update_enum_property_search_prop(self, context):
if prop.name == self.dummy_name:
setattr(context.data, self.prop_name, self.collection_identifiers[i].name)
predefined_type = self.collection_predefined_types[i].name
if self.first_launch:
self.first_launch = False
else:
context.window.screen = context.window.screen
if predefined_type:
try:
setattr(context.data, "ifc_predefined_type", predefined_type)
@@ -828,6 +832,7 @@ class BIM_OT_enum_property_search(bpy.types.Operator):
bl_idname = "bim.enum_property_search"
bl_label = "Search For Property"
bl_options = {"REGISTER", "UNDO"}
first_launch: bpy.props.BoolProperty(default=True, options={"SKIP_SAVE"})
dummy_name: bpy.props.StringProperty(name="Property", update=update_enum_property_search_prop)
collection_names: bpy.props.CollectionProperty(type=StrProperty)
collection_identifiers: bpy.props.CollectionProperty(type=StrProperty)