Use Mousewheel to change between vertex/edge/face mode

How would I use shift+mousewheel to change selection mode in edit mode? I would like to write an addon that achieves this. To be specific, for instance, I would like to be able to press shift+wheel up to change from vertex to edge or edge to face mode and vice versa with shift+wheel down. I have a basic idea how to do it by getting the current selection mode and how to set a new one combining it with an incrementing variable, except I don’t know how to trigger the script with the hotkey, nor if this method will work.

Any help would be greatly appreciated.

If you figure this out make sure to post here.

Hi Gizmo73, while not specifically covering the mouse wheel there is an addon that toggles between the selection modes in edit mesh and the UV editors


It uses the keys 1-3 (4 for ‘Limit selection to visible’) just like in 3dsMax, and it even works in the UV editor. The best part is that it does not conflict with the shortcuts of the layers in blender as its only used in edit mode. Apart from that the script is very small, you could use it as a base for you version.

While I can use this as a base, I’m not sure if I can adapt it to suit my needs. The script essentially is a one shot script that adds the number keys to the keymap. What I want to do is similar, basically instead of pressing the 2 key for edge select, I want to hold shift and scroll up once. This works for vertex and edge, but not face select, simce thew keymap is the same as edge select. That’s why I need to use the scroll wheel to increment a variable and then change the select mode based on the value of that variable. I’m not sure how to do this however.

I’ve got a working addon! although, there is some strange behaviour. I’ve set it up such that shift + wheel up or shift + wheel down activate the addon. However, when I am in vertex mode and press shift + scroll up, it jumps to face mode , the same happens in reverse. Not sure how to fix that, but apart from that it works. Here it is. Can you tell why it’s skipping?

bl_info = {
"name": "Scroll Select",
"author": "Lee Hesketh",
"version": (1, 0),
"blender": (2, 79, 0),
"location": "",
"description": "Change mesh selection mode with the scroll wheel",
"warning": "",
"wiki_url": "",
"category": "Mesh",
}

import bpy

class scrollSelect(bpy.types.Operator):
"""Change Selection mode with scroll wheel"""bl_idname = "mesh.scroll_select"
bl_label = "Scroll Select"
bl_options = { 'REGISTER', 'UNDO' }
@classmethod
def poll(cls, context):
[INDENT=2]return (context.active_object is not None) [/INDENT]
mode = 1
mode_type = [(True, False, False), (False, True, False), (False, False, True)]
def modal(self, context, event):
[INDENT=2]if event.type == 'WHEELUPMOUSE' and self.mode < 2:[/INDENT]
[INDENT=3]self.mode +=1[/INDENT]
[INDENT=2]elif event.type == 'WHEELDOWNMOUSE' and self.mode > 0:[/INDENT]
[INDENT=3]self.mode -=1[/INDENT]
[INDENT=2]context.tool_settings.mesh_select_mode = self.mode_type[self.mode][/INDENT]
[INDENT=2]if not event.shift:[/INDENT]
[INDENT=3]return {'FINISHED'}[/INDENT]
[INDENT=2]return {'RUNNING_MODAL'}
[/INDENT]

def invoke(self, context, event):
[INDENT=2]context.window_manager.modal_handler_add(self)[/INDENT]
[INDENT=2]return {'RUNNING_MODAL'}[/INDENT]


addon_keymaps = [] 
def register():wm = bpy.context.window_manager
km = wm.keyconfigs.default.keymaps['Mesh']
kmi = km.keymap_items.new(scrollSelect.bl_idname, 'WHEELDOWNMOUSE', 'PRESS', shift=True)
kmj = km.keymap_items.new(scrollSelect.bl_idname, 'WHEELUPMOUSE', 'PRESS', shift=True)
addon_keymaps.append((km, kmi))
addon_keymaps.append((km, kmj))
bpy.utils.register_module(__name__)


def unregister():for km, kmi in addon_keymaps:
km.keymap_items.remove(kmi)
addon_keymaps.clear()
bpy.utils.unregister_module(__name__)
if __name__ == "__main__":
register()

I wonder if it possible to make something similar with snaps, proportional types or manipulators orientation? for example holding Q and turning mouse wheel may switch transform orientation for active manipulator.