# Two operators with the same button, it's possible?

In my addon, I have a button that launches me an operator, and I want the same button gives me another operator (modal operator). It is possible to launch two operators with the same button? My modal operator :

def modal(self, context, event):
if event.type == 'RIGHTMOUSE':
...code...
return {'PASS_THROUGH'}

def execute(self, context):
wm = context.window_manager
return {'RUNNING_MODAL'}


Check Text Editor Templates: Operator Simple and Operator Modal

Imagine the modal operator has bl_idname = "object.some_generic_modal". In the execute function of your other (non modal) operator you could make a direct operator call:

def execute(self, context):

# call the other operator
bpy.ops.object.some_generic_modal()

return {'FINISHED'}


However, to avoid the separation and extra boilerplate, you might want to stick your one-off code in the invoke of the modal operator and call that directly instead.

To clarify: with the term one-off code I meant the code which just needs to be executed once, prior to the continuous modal operator.

• Thank you, it works. For cons, I did not understand well understood the second method : stick one-off code in the invoke … Here is my modal operator: def modal(self, context, event): if event.type == 'RIGHTMOUSE': ..... my code ..... return {'PASS_THROUGH'} def execute(self, context): wm = context.window_manager wm.modal_handler_add(self) return {'RUNNING_MODAL'} Feb 17 '15 at 9:32