How make “CustomTool(WorkSpaceTool)” call modal with specific “property”

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)    ) 

I think when you check your logs or system console it most likely will hind to the problem.
I guess you will find an error that indicates that the Modal Operator do not have an execute function or missing arguments: expecting 3 but got 1 in execute function.

Thanks man,
you got me the right hint !

Basically , my log sayd me that there is already a "custom tool already exist ",
So running the script was updating all the operators and panel but not the tool,
and maybe some more things.

UnRegistering the tool or Reloading the the file
have solved the issue…

Basically , my log sayd me that there is already a "custom tool already exist ",
So running the script was updating all the operators and panel but not the tool,
and maybe some more things.

UnRegistering the tool or Reloading the the file
have solved the issue…

Here an example of custom tool that keymap the mouse_left with alt shift ctrl and oskey
and a combo of 2 (oskey + alt) to set a property string , inside the operator.
To do different action/ operations based on these input.

remember to load the module for the property you need
from bpy.props import (StringProperty…

class CustomTool(WorkSpaceTool):  
    bl_space_type = 'VIEW_3D'
    bl_context_mode = 'OBJECT'
    bl_idname = "grabber.mycustom_tool"
    bl_label = "  TOOL NAME "
    bl_description = ("  your  tool ")
    bl_icon =  "ops.gpencil.draw.poly"          
    bl_widget = None 
    bl_keymap = (
        ("wm.your_operator_name", {"type": 'LEFTMOUSE', "value": 'PRESS'},
         {"properties": [("my_mode", "DEFAULT" )]}),
        ("wm.your_operator_name", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
         {"properties": [("my_mode", "CONTROL")]}),
        ("wm.your_operator_name", {"type": 'LEFTMOUSE', "value": 'PRESS', "alt": True},
         {"properties": [("my_mode", "ALT")]}),
        ("wm.your_operator_name", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
         {"properties": [("my_mode", "SHIFT")]}),
        ("wm.your_operator_name", {"type": 'LEFTMOUSE', "value": 'PRESS', "oskey": True},
         {"properties": [("my_mode", "OSKEY")]}),
        ("wm.your_operator_name", {"type": 'LEFTMOUSE', "value": 'PRESS', "oskey" : True , "alt": True},
         {"properties": [("my_mode", "OS+ALT")]}),         
    )

class CUSTOM_OPERATOR(bpy.types.Operator):
    bl_idname = "wm.your_operator_name"
    bl_label = "test operator"
    
    my_mode: bpy.props.StringProperty(name="MODES_STRING")

    def invoke....... continue with your operator