# set special mouse button to toggle between selection modes

I have a mouse with two additional buttons and I wanted to create shrtcuts for them. I succecfully managed to make one toggle between solid/wireframe view and the other to toggle between edit/object mode, but I wanted to set the second one to toggle between selection modes (so that if I pressed it while in vertex selection mode, I would get edge selection mode, if in edge, get faces, if in faces, get vertex). All I managed was to make it set one of them on and off, regardless of the other.

To cycle through the possible selection options, you will need an operator that looks at the current selection to choose which selection option should be enabled.

That can be done in a simple operator, which you can then assign to your mouse button.

class SelectCycle(bpy.types.Operator):
bl_idname = 'mesh.select_cycle'
bl_label = 'Cycles through selection modes.'

def execute(self, context):
ts = context.tool_settings
if ts.mesh_select_mode[0]:
ts.mesh_select_mode = [False,True,False]
elif ts.mesh_select_mode[1]:
ts.mesh_select_mode = [False,False,True]
else:
ts.mesh_select_mode = [True,False,False]
return {'FINISHED'}


You can find a copy of this as an addon here, so you can enable it in your startup.blend.

In your input settings, you just need to enter mesh.select_cycle for the idname and choose the mouse button.

• Wow... If anyone uses this, there is a bonus - if you use this in object mode, it switches to edit mode instead. Maybe this is not intentional, but it's really nice – aky-her Jan 7 '18 at 6:34
• That won't be from this code. Maybe you already have that button set to switch to edit mode. – sambler Jan 7 '18 at 6:45
• oh, you're right, sorry for chaos – aky-her Jan 7 '18 at 11:52