From 920d09696e9a6a82e93fbf147ade0ab2cf64e513 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 2 Nov 2017 23:30:01 +1100 Subject: UI: store tool index of non-active tools --- .../scripts/startup/bl_ui/space_toolsystem_common.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'release') diff --git a/release/scripts/startup/bl_ui/space_toolsystem_common.py b/release/scripts/startup/bl_ui/space_toolsystem_common.py index 69f4b0bbf2a..269cde71b4b 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_common.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py @@ -97,6 +97,9 @@ class ToolSelectPanelHelper: # {tool_name: (keymap, keymap_idname, manipulator_group_idname), ...} cls._tool_keymap = {} + # {tool_name_first: index_in_group, ...} + cls._tool_group_active = {} + # ignore in background mode if kc is None: return @@ -129,9 +132,11 @@ class ToolSelectPanelHelper: continue if self._tool_is_group(item): - index = 0 is_active = False - for i, sub_item in enumerate(item): + i = 0 + for sub_item in item: + if item is None: + continue text, mp_idname, actions = sub_item km, km_idname = (None, None) if actions is None else self._tool_keymap[text] is_active = ( @@ -141,7 +146,15 @@ class ToolSelectPanelHelper: if is_active: index = i break + i += 1 del i, sub_item + + if is_active: + # not ideal, write this every time :S + self._tool_group_active[item[0][0]] = index + else: + index = self._tool_group_active.get(item[0][0], 0) + item = item[index] use_menu = True else: -- cgit v1.2.3