Fix T48802 Unwrap buttons, can't add hotkey in 3DView's UV Unwrap menu.
authorBastien Montagne <montagne29@wanadoo.fr>
Thu, 7 Jul 2016 15:03:30 +0000 (17:03 +0200)
committerBastien Montagne <montagne29@wanadoo.fr>
Thu, 7 Jul 2016 15:06:53 +0000 (17:06 +0200)
Those unwrap operators are a bit tricky, some are available from both 3DView and UVEditor, others only from 3DView...

Hacked around this by returning Mesh keymap for UV_OT ops for specific 3DView/MeshEditMode context.

source/blender/windowmanager/intern/wm_keymap.c

index 72b26cc6207b62d05b82e7b056c211670f365e11..184ff09a76ea98f81cde26de3dc1930ea77d28c2 100644 (file)
@@ -1787,7 +1787,17 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
        }
        /* UV Editor */
        else if (STRPREFIX(opname, "UV_OT")) {
-               km = WM_keymap_find_all(C, "UV Editor", 0, 0);
+               /* Hack to allow using UV unwrapping ops from 3DView/editmode.
+                * Mesh keymap is probably not ideal, but best place I could find to put those. */
+               if (sl->spacetype == SPACE_VIEW3D) {
+                       km = WM_keymap_find_all(C, "Mesh", 0, 0);
+                       if (km && km->poll && !km->poll(C)) {
+                               km = NULL;
+                       }
+               }
+               if (!km) {
+                       km = WM_keymap_find_all(C, "UV Editor", 0, 0);
+               }
        }
        /* Node Editor */
        else if (STRPREFIX(opname, "NODE_OT")) {