i am making a custom tool, i would like to have different behaviour if i use the tool holding Alt, Ctrl, Shift… in the templates there is an Half/example in the UItool simple. But i cant make it work in my own script.
bl_keymap = ( ("view3d.select_circle", {"type": 'LEFTMOUSE', "value": 'PRESS'},
{"properties": [("wait_for_input", False)]}),
("view3d.select_circle", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
{"properties": [("mode", 'SUB'), ("wait_for_input", False)]}),
)
These lines keymap the tool 2 times, to the same “operator”, But setting the properties: Wait_for_input and mode. So if i understand correctly i can add a property to my operator to choose if create cubes or sphere . and i should be able to set this property from here.
What i am messing around ?
I post here the parts of the script i think are useful…
Ho i am using the tool keymap to call the operator , and the property i would like to set…
and my operator just print the mouse location and these property.
I commented two lines, that will make me print these exact values,
right now the print just give me an empty string and a 0.
Basically never the setting i do in the tool keymap.
Thanks for your time
class CustomTool(WorkSpaceTool):
bl_space_type = 'VIEW_3D'
bl_context_mode = 'OBJECT'
bl_idname = "grabber.mycustom_tool"
bl_label = " GRABBER "
bl_description = (" move tool ")
bl_icon = "ops.gpencil.draw.poly"
bl_widget = None
bl_keymap = (
("wm.modal_grabber", {"type": 'LEFTMOUSE', "value": 'PRESS'},
{"properties": [("my_mode2", 1 )]}),
("wm.modal_grabber", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
{"properties": [("my_mode", "B")]}),
)
class CUSTOM_GRABBER(bpy.types.Operator):
bl_idname = "wm.modal_grabber"
bl_label = "test Modal grabber"
my_mode2: bpy.props.IntProperty(name="MODES_INT")
my_mode: bpy.props.StringProperty(name="MODES_STR")
def invoke(self, context, event):
print("INVOKE")
# self.my_mode2 = 66
# self.my_mode = "number"
self.execute(context)
return {'RUNNING_MODAL'}
def modal(self, context, event):
if event.type == 'MOUSEMOVE':
print("Mouse moved to " + str(event.mouse_region_x) + " " + str(event.mouse_region_y) )
print (bpy.context.scene.CUSTOM_DATA.MouseL)
context.area.tag_redraw()
print("MY MODE IS = this")
print("mode = " + self.my_mode)
print("mode2 = "+ str(self.my_mode2) )