I have an add-on that I want to use as a Workspace Tool (similar to the Bevel Tool). How can I set up my operator's modal
call to only run the operator once and simply adjust the operator's property when the user moves the mouse left or right? I'd like behavior similar to the Redo Panel where the state is reverted every time the property is adjusted. My operator adds points to the object and adjusts them based on the operator's radius property. Currently points are being added with every mouse move which isn't good. Thank you!
first_mouse_x: IntProperty()
first_value: FloatProperty()
def modal(self, context, event):
if event.type == 'MOUSEMOVE':
delta = self.first_mouse_x - event.mouse_x
my_operator(self,context,self.first_value + delta * 0.01) #how can I reset the state with every mouse move?
elif event.type == 'LEFTMOUSE':
return {'FINISHED'}
elif event.type in {'RIGHTMOUSE', 'ESC'}:
my_operator(self,context,self.first_value)
return {'CANCELLED'}
return {'RUNNING_MODAL'}
bpy.ops.ed.undo_push()
is also a good option. $\endgroup$