diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-05-21 12:54:47 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-05-21 13:46:26 +0300 |
commit | 3b1b625eadd02024d2d82b0fc42e0263c1654799 (patch) | |
tree | 69df87fbab53a35e590250a3fbb405384cd1cc7d /release/scripts | |
parent | 3102821c9ccc9535cd0f8ed1208287a52a306861 (diff) |
UI: use spacebar for toolbar
- This allows quick, consistent toolbar access
w/o conflicting w/ the keymap.
Where pressing space before a key activates that operator as a tool
instead of running immediately.
- Search can still be accessed by pressing spacebar again.
- When there is no toolbar for a space, operator search still opens.
Diffstat (limited to 'release/scripts')
-rw-r--r-- | release/scripts/startup/bl_operators/wm.py | 8 | ||||
-rw-r--r-- | release/scripts/startup/bl_ui/space_toolsystem_common.py | 16 |
2 files changed, 20 insertions, 4 deletions
diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index 83a5eefcbe5..f18464a6614 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -2369,7 +2369,9 @@ class WM_OT_toolbar(Operator): cls = ToolSelectPanelHelper._tool_class_from_space_type(space_type) if cls is None: - self.report({'WARNING'}, f"Toolbar not found for {space_type!r}") + # self.report({'WARNING'}, f"Toolbar not found for {space_type!r}") + # Passthrough to running search directly. + bpy.ops.wm.search_menu('INVOKE_DEFAULT') return {'CANCELLED'} wm = context.window_manager @@ -2379,7 +2381,9 @@ class WM_OT_toolbar(Operator): layout = popover.layout cls.draw_cls(layout, context, detect_layout=False) - # wm.popup_menu(draw_menu) # this also works + layout.operator_context = 'INVOKE_DEFAULT' + layout.operator("wm.search_menu") + wm.popover(draw_menu, keymap=keymap) return {'FINISHED'} diff --git a/release/scripts/startup/bl_ui/space_toolsystem_common.py b/release/scripts/startup/bl_ui/space_toolsystem_common.py index fd2300dab22..137e60450d5 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_common.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py @@ -598,6 +598,9 @@ def keymap_from_context(context, space_type): keymap.keymap_items.remove(kmi) + kmi_search = wm.keyconfigs.find_item_from_operator(idname="wm.toolbar")[1] + kmi_search_type = None if not kmi_search else kmi_search.type + items = [] cls = ToolSelectPanelHelper._tool_class_from_space_type(space_type) for i, item in enumerate( @@ -613,10 +616,10 @@ def keymap_from_context(context, space_type): if item.keymap: kmi_first = item.keymap[0].keymap_items[0] - keymap_found, kmi_found = wm.keyconfigs.find_item_from_operator( + kmi_found = wm.keyconfigs.find_item_from_operator( idname=kmi_first.idname, # properties=kmi_first.properties, # prevents matches, don't use. - ) + )[1] if kmi_found is not None: kmi_found_type = kmi_found.type # Only for single keys. @@ -633,6 +636,15 @@ def keymap_from_context(context, space_type): key_modifier=kmi_found.key_modifier, ) kmi.properties.name = item.text + + # Disallow overlap + if kmi_search_type == kmi_found_type: + kmi_search_type = None + + # Support double-tap for search. + if kmi_search_type: + keymap.keymap_items.new("wm.search_menu", type=kmi_search_type, value='PRESS') + wm.keyconfigs.update() return keymap |