Page MenuHome

Clear filter for enum search menu
AbandonedPublic

Authored by Aleksandr Zinovev (raa) on Feb 15 2017, 11:06 PM.

Details

Summary

Blender uses the same search filter value for all enum search menus.
So if we select an item in some enum search menu, we have to delete the filter to view available options in other search menus.
To fix it the filter should be cleared if its value is not a substring of the current enum item's name.

Diff Detail

Repository
rB Blender

Event Timeline

Aleksandr Zinovev (raa) retitled this revision from to Clear filter for enum search menu.
Aleksandr Zinovev (raa) updated this object.
Aleksandr Zinovev (raa) set the repository for this revision to rB Blender.

Fix looks OK off hands, but do you have an example to check it?

source/blender/windowmanager/intern/wm_operators.c
1131

Can rather use STREQLEN macro

1132

Just do search[0] = '\0';, it’s simpler in that case ;)

You can test the patch using this script:

import bpy

class TestSearchA(bpy.types.Operator):
    bl_idname = "test.search_a"
    bl_label = "Search A"
    bl_property = "search_a"

    search_a = bpy.props.EnumProperty(items=(
        ('ITEM_A1', "Item A1", ""),
        ('ITEM_A2', "Item A2", ""),
        ('ITEM_A3', "Item A3", ""),
    ))

    def execute(self, context):
        return {'CANCELLED'}

    def invoke(self, context, event):
        context.window_manager.invoke_search_popup(self)
        return {'FINISHED'}


class TestSearchB(bpy.types.Operator):
    bl_idname = "test.search_b"
    bl_label = "Search B"
    bl_property = "search_b"

    def get_items(cls, context):
        return (
            ('ITEM_B1', "Item B1", ""),
            ('ITEM_B2', "Item B2", ""),
            ('ITEM_B3', "Item B3", ""),
        )
    wrong_prop = bpy.props.StringProperty()
    search_b = bpy.props.EnumProperty(items=get_items)

    def execute(self, context):
        return {'CANCELLED'}

    def invoke(self, context, event):
        context.window_manager.invoke_search_popup(self)
        return {'FINISHED'}


class TestPanel(bpy.types.Panel):
    bl_label = "Test Panel"
    bl_space_type = 'TEXT_EDITOR'
    bl_region_type = 'UI'
    
    def draw(self, context):
        layout = self.layout
        layout.operator("test.search_a")
        layout.operator("test.search_b")
   
        
bpy.utils.register_class(TestSearchA)
bpy.utils.register_class(TestSearchB)
bpy.utils.register_class(TestPanel)