Can the name field of the WindowManager´s "invoke_search_popup" method be reset? I´m using the "invoke_search_popup" method of the Window Manager to create a search box which enables me to find some items in a predefined collection of objects.



The thing is, that sometimes I switch from some type of collection to another. Let´s say that I first search in a collection of Objects, and then in a collection of Groups. If I just selected an Object the first time, on the next one it´s name will appear as a suggestion or as the "last item used" in the name field of the new Groups search box, filtering all search results.



I understand that this happens globally because the window manager instance is created once, and then on, used again and again. So I want to know if at least there is some way to recreate or reload the instance, so that the name field becomes empty again.

It happens that when working on long sessions it´s annoying to first have to delete the name field everytime to clean the search results.
I would like to have it clean everytime I call it, because it makes much more sense for the workflow I´m using. If there´s a way to achieve this, I could even clean it only when switching collections type, which is smarter.

Try this code. Select an item, and then, call the script again.

import bpy

class Operator(bpy.types.Operator):
    bl_idname = "operator.menu"
    bl_label = "Search"
    bl_description = "Whatever"
    bl_options = {'REGISTER', 'INTERNAL'}
    bl_property = "enum"

    def scene_items(self, context):
        return [(ob.name, ob.name, '') for ob in bpy.data.objects]
    enum = bpy.props.EnumProperty(items=scene_items)

    def execute(self, context):
        self.report({'INFO'}, "The item just got selected")
        return {"FINISHED"}

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

def register():
    bpy.utils.register_module(__name__)
def unregister():
    bpy.utils.unregister_module(__name__)

if __name__ == "__main__":
    register()
    bpy.ops.operator.menu("INVOKE_DEFAULT")
This got changed on Blender 2.79 due to a bug report I sent.
The popup menu doesn't show the last search anymore. It gets emptied, showing all the list again.
It would be cool though, if the scripter could be able to choose if he/she wants to clear the field or not, but maybe it will be necessary to file a feature request for that.