BlenderKit: close popup menu when it makes sense after running an operator
This commit is contained in:
parent
ac92e71d98
commit
7a871722ab
|
@ -97,6 +97,8 @@ def get_categories_filepath():
|
|||
return os.path.join(tempdir, 'categories.json')
|
||||
|
||||
dirs_exist_dict = {}#cache these results since this is used very often
|
||||
# this causes the function to fail if user deletes the directory while blender is running,
|
||||
# but comes back when blender is restarted.
|
||||
def get_temp_dir(subdir=None):
|
||||
|
||||
user_preferences = bpy.context.preferences.addons['blenderkit'].preferences
|
||||
|
|
|
@ -1458,6 +1458,12 @@ class SearchOperator(Operator):
|
|||
bl_description = "Search online for assets"
|
||||
bl_options = {'REGISTER', 'UNDO', 'INTERNAL'}
|
||||
|
||||
esc: BoolProperty(name="Escape window",
|
||||
description="Escape window right after start",
|
||||
default=False,
|
||||
options={'SKIP_SAVE'}
|
||||
)
|
||||
|
||||
own: BoolProperty(name="own assets only",
|
||||
description="Find all own assets",
|
||||
default=False)
|
||||
|
@ -1506,6 +1512,8 @@ class SearchOperator(Operator):
|
|||
|
||||
def execute(self, context):
|
||||
# TODO ; this should all get transferred to properties of the search operator, so sprops don't have to be fetched here at all.
|
||||
if self.esc:
|
||||
bpy.ops.view3d.close_popup_button('INVOKE_DEFAULT')
|
||||
sprops = utils.get_search_props()
|
||||
if self.author_id != '':
|
||||
sprops.search_keywords = ''
|
||||
|
|
|
@ -1206,6 +1206,7 @@ def draw_asset_context_menu(layout, context, asset_data, from_panel=False):
|
|||
op.author_id = author_id
|
||||
|
||||
op = layout.operator('view3d.blenderkit_search', text='Search Similar')
|
||||
op.esc = True
|
||||
op.tooltip = 'Search for similar assets in the library'
|
||||
# build search string from description and tags:
|
||||
op.keywords = asset_data['name']
|
||||
|
@ -1721,6 +1722,7 @@ class AssetPopupCard(bpy.types.Operator, ratings_utils.RatingsProperties):
|
|||
op.url = url
|
||||
|
||||
op = button_row.operator('view3d.blenderkit_search', text="Find Assets By Author")
|
||||
op.esc = True
|
||||
op.keywords = ''
|
||||
op.author_id = self.asset_data['author']['id']
|
||||
|
||||
|
|
Loading…
Reference in New Issue