The following modal operator (after launched from F3) should report the type of left-clicked screen area.
*But instead of reporting the type of clicked area - it reports the type of area from which it was initially started:
from bpy.types import Operator
from bpy.utils import register_class
class Get_Area_Type(Operator):
"""Report the type of area beneath the mouse cursor"""
bl_idname = "screen.get_area_type"
bl_label = "Get Area Type"
bl_options = set()
def modal(self,context,event):
if event.type in ('RIGHTMOUSE','ESC'):
return self.cancel(context)
if event.type == 'LEFTMOUSE':
self.report({'INFO'}, context.area.type)
return {'RUNNING_MODAL'}
def invoke(self,context,event):
context.window_manager.modal_handler_add(self)
context.window.cursor_set("EYEDROPPER")
return {'RUNNING_MODAL'}
def cancel(self,context):
self.report({'INFO'}, 'Operator Stopped')
return {'CANCELLED'}
register_class(Get_Area_Type)
E.g., when we launch operator from 3D Viewport and click on Outliner:
- it should report 'OUTLINER'
- but instead it reports 'VIEW_3D' (the type of area from which it was launched)
How to fix this problem?