UI: proof of concept keymap for the popup toolbar
This commit is contained in:
@@ -2360,6 +2360,8 @@ class WM_OT_toolbar(Operator):
|
||||
bl_idname = "wm.toolbar"
|
||||
bl_label = "Toolbar"
|
||||
|
||||
keymap = None
|
||||
|
||||
def execute(self, context):
|
||||
space_type = context.space_data.type
|
||||
from bl_ui.space_toolsystem_common import ToolSelectPanelHelper
|
||||
@@ -2368,12 +2370,30 @@ class WM_OT_toolbar(Operator):
|
||||
self.report({'WARNING'}, f"Toolbar not found for {space_type!r}")
|
||||
return {'CANCELLED'}
|
||||
|
||||
def draw_menu(popover, context):
|
||||
cls.draw_cls(popover.layout, context, detect_layout=False)
|
||||
|
||||
wm = context.window_manager
|
||||
|
||||
if WM_OT_toolbar.keymap is None:
|
||||
keyconf = wm.keyconfigs.active
|
||||
km = keyconf.keymaps.new("Toolbar Popup", space_type='EMPTY', region_type='TEMPORARY')
|
||||
WM_OT_toolbar.keymap = km
|
||||
|
||||
# Example
|
||||
for key, value in (
|
||||
('G', "Move"),
|
||||
('R', "Rotate"),
|
||||
('S', "Scale"),
|
||||
('C', "Select Circle"),
|
||||
('B', "Select Border"),
|
||||
):
|
||||
kmi = km.keymap_items.new("wm.tool_set_by_name", key, 'PRESS')
|
||||
kmi.properties.name = value
|
||||
|
||||
def draw_menu(popover, context):
|
||||
layout = popover.layout
|
||||
cls.draw_cls(layout, context, detect_layout=False)
|
||||
|
||||
# wm.popup_menu(draw_menu) # this also works
|
||||
wm.popover(draw_menu)
|
||||
wm.popover(draw_menu, keymap=WM_OT_toolbar.keymap)
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user