Fix T48802 Unwrap buttons, can't add hotkey in 3DView's UV Unwrap menu.

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.
This commit is contained in:
2016-07-07 17:03:30 +02:00
parent c8be112523
commit b9dbcf406e

View 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")) {