* Fix small bug in Python operator example; improved example of modal operator
This commit is contained in:
parent
1958fda91f
commit
13d829e57d
@ -26,8 +26,8 @@ class CustomDrawOperator(bpy.types.Operator):
|
||||
return {'FINISHED'}
|
||||
|
||||
def invoke(self, context, event):
|
||||
context.window_manager.fileselect_add(self)
|
||||
return {'RUNNING_MODAL'}
|
||||
wm = context.window_manager
|
||||
return wm.invoke_props_dialog(self)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
@ -40,15 +40,17 @@ class ModalOperator(bpy.types.Operator):
|
||||
elif event.type == 'LEFTMOUSE': # Confirm
|
||||
return {'FINISHED'}
|
||||
elif event.type in ('RIGHTMOUSE', 'ESC'): # Cancel
|
||||
context.object.location.x = self.init_loc_x
|
||||
return {'CANCELLED'}
|
||||
|
||||
return {'RUNNING_MODAL'}
|
||||
|
||||
def invoke(self, context, event):
|
||||
self.init_loc_x = context.object.location.x
|
||||
self.value = event.mouse_x
|
||||
self.execute(context)
|
||||
|
||||
print(context.window_manager.modal_handler_add(self))
|
||||
context.window_manager.modal_handler_add(self)
|
||||
return {'RUNNING_MODAL'}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user