Mapping hotkeys - a hint please...

Something that’s always defeated me in 2.5/6 is the hotkey ‘editor’.

I tried again today to remap a key (in 2.63 64-bit Windoze) and failed. Maybe someone can help me out?

I was weight painting and wanted to map the ‘F’ key back to the ‘Face Select’ mode toggle.
By default ‘F’ appears to be mapped to a function for changing brush size. (I don’t do that nearly
so often as switching in and out of face select - to make the verts/edges visible).

OK. So I open up the User Preferences Input panel and find the 3D-View/weight paint panel and the current
‘F’ key mapping. Seems to be “Radial Control” - Makes sense. Apparently mapped to shift-F also.

Next problem is, what is the Python operator? If I wave over the face select mode button, I get a hint that
it’s ‘Mesh.use_paint_mask’. So I type that in the ‘operator’ box in the hot-key.

The input box refuses the uppercase ‘M’ and presents me with ‘mesh.use_paint_mask’. The ‘title’ of
the hot key changes to ‘MESH_OT_use_paint_mask’, which I took as a hopeful sign that it at least
recognised the name, but possibly, in fact, meant the opposite…

But back in the 3D-view, while the ‘F’ key no longer brings up the brush size control, it has no effect
on the face select mode toggle.

OK. So I rummaged in the Python API reference pages (By now, you’ve guessed that Python is a
mystery to me, but I really wanted to fix that key!) I spotted that msg.set_paint_mask was in fact
a boolean variable. Then I rummaged further looking for a way to toogle a boolean, and found:

bpy.ops.wm.context_set_boolean(data_path="", value=True)

Ah ha! I thought. I just need to use something like:

bpy.ops.wm.context_set_boolean(“Mesh.use_paint_mask”, !Mesh.use_paint_mask)

But truly, a little knowledge is a dangerous thing. Blender promptly crashed.

I picked blender up and dusted it off, then looked up a Python language reference and
boolean operators. Okay. It’s not ‘!’, it’s ‘not’.

Right. So this time I paste in:

bpy.ops.wm.context_set_boolean(“Mesh.use_paint_mask”, not Mesh.use_paint_mask)

Poof! Another invitation to debug blender (yep I have a debugger installed).

Can someone give me hint here? What’s the ‘right’ way to toggle this switch?
Does changing hotkeys really need a knowledge of Python and the Blender API?

Thanks in advance.


There already is a hotkey for that, it’s “M”. so if you want to change it, go back into the user preferences and it’s a Contex Toggle right below the Radial Controls you mentioned in your post. All you need to do then is change it to whatever you want.

Thanks rickgski.

In fact ‘M’ just brings up the ‘change bone layers’ popup.

But by copying and pasting the shortcut entries from ‘M’ back to the ‘F’ key I get a functional hotkey
to toggle the face select mode.


Sorry, in my version M in weight paint mode does change the face selection not bone layers, but glad you got it worked out.