Keymap: only use MMB workaround whe MMB is enabled
authorCampbell Barton <ideasman42@gmail.com>
Wed, 5 Dec 2018 23:02:25 +0000 (10:02 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 5 Dec 2018 23:05:53 +0000 (10:05 +1100)
Using double-click with selection breaks selection cycling behavior
(making you have to wait to click again to cycle-select the next item).

release/scripts/presets/keyconfig/blender.py
release/scripts/presets/keyconfig/blender_27x.py
release/scripts/presets/keyconfig/keymap_data/blender_default.py
source/blender/makesrna/intern/rna_userdef.c

index bda19e075a384ded378aadea2b69ef6c292c344e..ff8edbdede7caa31fd552f6f9869dfb68c8c368c 100644 (file)
@@ -105,14 +105,17 @@ blender_default = bpy.utils.execfile(os.path.join(dirname, "keymap_data", "blend
 
 
 def load():
+    from bpy import context
     from bl_keymap_utils.io import keyconfig_init_from_data
 
-    kc = bpy.context.window_manager.keyconfigs.new(idname)
+    prefs = context.user_preferences
+    kc = context.window_manager.keyconfigs.new(idname)
     kc_prefs = kc.preferences
 
     keyconfig_data = blender_default.generate_keymaps(
         blender_default.Params(
             select_mouse=kc_prefs.select_mouse,
+            use_mouse_emulate_3_button=prefs.inputs.use_mouse_emulate_3_button,
             spacebar_action=kc_prefs.spacebar_action,
             use_select_all_toggle=kc_prefs.use_select_all_toggle,
             use_v3d_tab_menu=kc_prefs.use_v3d_tab_menu,
index 738f7523e115f264c5a724bc30a3888ae8a1afd2..d60324f22d6f6bd83b17393230078383e9566200 100644 (file)
@@ -42,14 +42,17 @@ class Prefs(bpy.types.KeyConfigPreferences):
 blender_default = bpy.utils.execfile(os.path.join(dirname, "keymap_data", "blender_default.py"))
 
 def load():
+    from bpy import context
     from bl_keymap_utils.io import keyconfig_init_from_data
 
-    kc = bpy.context.window_manager.keyconfigs.new(idname)
+    prefs = context.user_preferences
+    kc = context.window_manager.keyconfigs.new(idname)
     kc_prefs = kc.preferences
 
     keyconfig_data = blender_default.generate_keymaps(
         blender_default.Params(
             select_mouse=kc_prefs.select_mouse,
+            use_mouse_emulate_3_button=prefs.inputs.use_mouse_emulate_3_button,
             spacebar_action='SEARCH',
             use_select_all_toggle=True,
             legacy=True,
index 09fdd2029326d6e26516fe79f1380b46a9da4da8..78f71999065672f992442a53395abf4425bbf5c6 100644 (file)
@@ -34,6 +34,7 @@ class Params:
         "context_menu_event",
         "cursor_set_event",
         "cursor_tweak_event",
+        "use_mouse_emulate_3_button",
 
         # User preferences.
         #
@@ -52,6 +53,7 @@ class Params:
             *,
             legacy=False,
             select_mouse='RIGHT',
+            use_mouse_emulate_3_button=False,
 
             # User preferences.
             spacebar_action='TOOL',
@@ -97,6 +99,8 @@ class Params:
             self.cursor_set_event = {"type": 'RIGHTMOUSE', "value": 'PRESS', "shift": True}
             self.cursor_tweak_event = {"type": 'EVT_TWEAK_R', "value": 'ANY', "shift": True}
 
+        self.use_mouse_emulate_3_button = use_mouse_emulate_3_button
+
         # User preferences
         self.spacebar_action = spacebar_action
         self.use_select_all_toggle = use_select_all_toggle
@@ -3766,13 +3770,7 @@ def km_mesh(params):
          {"properties": [("vertex_only", True)]}),
         # Selection modes.
         *_template_items_editmode_mesh_select_mode(),
-        # Loop Select with alt, and double click in case MMB emulation is on.
-        ("mesh.loop_select", {"type": params.select_mouse, "value": 'DOUBLE_CLICK'},
-         {"properties": [("extend", False), ("deselect", False), ("toggle", False)]}),
-        ("mesh.loop_select", {"type": params.select_mouse, "value": 'DOUBLE_CLICK', "shift": True},
-         {"properties": [("extend", True), ("deselect", False), ("toggle", False)]}),
-        ("mesh.loop_select", {"type": params.select_mouse, "value": 'DOUBLE_CLICK', "alt": True},
-         {"properties": [("extend", False), ("deselect", True), ("toggle", False)]}),
+        # Loop Select with alt. Double click in case MMB emulation is on (below).
         ("mesh.loop_select", {"type": params.select_mouse, "value": params.select_mouse_value, "alt": True},
          {"properties": [("extend", False), ("deselect", False), ("toggle", False)]}),
         ("mesh.loop_select", {"type": params.select_mouse, "value": params.select_mouse_value, "shift": True, "alt": True},
@@ -3856,6 +3854,16 @@ def km_mesh(params):
         *_template_items_proportional_editing(connected=True),
     ])
 
+    if params.use_mouse_emulate_3_button:
+        items.extend([
+            ("mesh.loop_select", {"type": params.select_mouse, "value": 'DOUBLE_CLICK'},
+             {"properties": [("extend", False), ("deselect", False), ("toggle", False)]}),
+            ("mesh.loop_select", {"type": params.select_mouse, "value": 'DOUBLE_CLICK', "shift": True},
+             {"properties": [("extend", True), ("deselect", False), ("toggle", False)]}),
+            ("mesh.loop_select", {"type": params.select_mouse, "value": 'DOUBLE_CLICK', "alt": True},
+             {"properties": [("extend", False), ("deselect", True), ("toggle", False)]}),
+        ])
+
     if params.legacy:
         items.extend([
             ("mesh.poke", {"type": 'P', "value": 'PRESS', "alt": True}, None),
index 3bdec89ce5b14a4a221ee918bc5f7fa9731363f7..00e7c42d5bbab8cc5cf80afced9e1cdfc581503d 100644 (file)
@@ -244,6 +244,11 @@ static void rna_userdef_ndof_deadzone_update(Main *UNUSED(bmain), Scene *UNUSED(
 }
 #endif
 
+static void rna_userdef_keyconfig_reload_update(bContext *C, Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
+{
+       WM_keyconfig_reload(C);
+}
+
 static void rna_userdef_timecode_style_set(PointerRNA *ptr, int value)
 {
        UserDef *userdef = (UserDef *)ptr->data;
@@ -4772,6 +4777,8 @@ static void rna_def_userdef_input(BlenderRNA *brna)
        RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_TWOBUTTONMOUSE);
        RNA_def_property_ui_text(prop, "Emulate 3 Button Mouse",
                                 "Emulate Middle Mouse with Alt+Left Mouse (doesn't work with Left Mouse Select option)");
+       RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+       RNA_def_property_update(prop, 0, "rna_userdef_keyconfig_reload_update");
 
        prop = RNA_def_property(srna, "use_emulate_numpad", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_NONUMPAD);