Brecht Van Lommel
088be7eb2f
For Blender builtin configurations the option to choose the select mouse remains and is now also in the splash screen. It works by changing the keymap dynamically in the script, rather than using special events. The system of automatic switching of events was not flexible enough to deal with side effects that require further keymap changes, so it is now under more manual control in the script. This breaks compatibility for some scripts and exported key configurations. These can be fixed by replacing SELECTMOUSE, ACTIONMOUSE, EVT_TWEAK_S and EVT_TWEAK_A with appropriate LEFTMOUSE, RIGHTMOUSE, EVT_TWEAK_L and EVT_TWEAK_R events. Other than that, there should be no functional changes.
36 lines
1020 B
Python
36 lines
1020 B
Python
# This example adds an object mode tool to the toolbar.
|
|
# This is just the circle-select tool.
|
|
import bpy
|
|
from bpy.utils.toolsystem import ToolDef
|
|
|
|
@ToolDef.from_fn
|
|
def my_tool():
|
|
def draw_settings(context, layout, tool):
|
|
props = tool.operator_properties("view3d.select_circle")
|
|
layout.prop(props, "radius")
|
|
return dict(
|
|
text="My Circle Select",
|
|
description=(
|
|
"This is a tooltip\n"
|
|
"with multiple lines"
|
|
),
|
|
icon="ops.generic.select_circle",
|
|
widget=None,
|
|
keymap=(
|
|
("view3d.select_circle", dict(deselect=False), dict(type='LEFTMOUSE', value='PRESS')),
|
|
("view3d.select_circle", dict(deselect=True), dict(type='LEFTMOUSE', value='PRESS', ctrl=True)),
|
|
),
|
|
draw_settings=draw_settings,
|
|
)
|
|
|
|
|
|
def register():
|
|
bpy.utils.register_tool('VIEW_3D', 'OBJECT', my_tool)
|
|
|
|
|
|
def unregister():
|
|
bpy.utils.unregister_tool('VIEW_3D', 'OBJECT', my_tool)
|
|
|
|
if __name__ == "__main__":
|
|
register()
|