From b2d8f834446c5545efae8a824a6197e2b338ec00 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 13 Jul 2018 09:18:46 +0200 Subject: Keymap: run search by its key in tools popup The button & key are displayed here, so its best if the shortcut works. --- .../startup/bl_ui/space_toolsystem_common.py | 27 +++++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'release/scripts') diff --git a/release/scripts/startup/bl_ui/space_toolsystem_common.py b/release/scripts/startup/bl_ui/space_toolsystem_common.py index 7fe8360b4da..ffd95ec7c64 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_common.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py @@ -625,6 +625,16 @@ def keymap_from_context(context, space_type): Keymap for popup toolbar, currently generated each time. """ + def modifier_keywords_from_item(kmi): + return { + "any": kmi.any, + "shift": kmi.shift, + "ctrl": kmi.ctrl, + "alt": kmi.alt, + "oskey": kmi.oskey, + "key_modifier": kmi.key_modifier, + } + use_search = False # allows double tap use_simple_keymap = False @@ -677,12 +687,7 @@ def keymap_from_context(context, space_type): idname="wm.tool_set_by_name", type=kmi_found_type, value='PRESS', - any=kmi_found.any, - shift=kmi_found.shift, - ctrl=kmi_found.ctrl, - alt=kmi_found.alt, - oskey=kmi_found.oskey, - key_modifier=kmi_found.key_modifier, + **modifier_keywords_from_item(kmi_found), ) kmi.properties.name = item.text @@ -695,6 +700,16 @@ def keymap_from_context(context, space_type): # Support double-tap for search. if kmi_search_type: keymap.keymap_items.new("wm.search_menu", type=kmi_search_type, value='PRESS') + else: + # The shortcut will show, so we better support running it. + kmi_search = wm.keyconfigs.find_item_from_operator(idname="wm.search_menu")[1] + if kmi_search: + keymap.keymap_items.new( + "wm.search_menu", + type=kmi_search.type, + value='PRESS', + **modifier_keywords_from_item(kmi_search), + ) wm.keyconfigs.update() return keymap -- cgit v1.2.3