3
$\begingroup$

I want to display a custom menu when it will be in the left top corner of the 3D View, over the view name ("User Persp" etc).

I guess this is the long way, but if I'll also know the window location and area (already answered here How to get mouse position in a window with Python?), and mouse position, then I'll be able to calculate if the mouse is in the right spot or not.

$\endgroup$

1 Answer 1

8
$\begingroup$

You can query the region's width from bpy.types.Region.width

I'm not sure if the toolbar region is always the second region (region[1]) in the bpy.types.Area.regions list, but you can always just loop through and check the type:

for region in bpy.context.area.regions:
    if region.type == "TOOLS":
        width = region.width
        break

That'll pick the first region of type TOOLS, though afaik there can be only one.

$\endgroup$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .