addon_common
                                
                                 addon_common copied to clipboard
                                
                                    addon_common copied to clipboard
                            
                            
                            
                        Pass through events to Blender UI
I've been experimenting with creating UI with CookieCutter yesterday and I think I found a significant limitation in the way the whole library can be used. It seems to be impossible (just judging from event passing code) to pass any events to Blender UI when a CookieCutter-based operator is running modal.
I see where the limitation is coming from since it was built primarily for Retopoflow and similar tools implementing their own edit modes basically. But since the modal operators in Blender can be run alongside each other it makes it possible to make UI-only operators implementing no real actions (e.g. useful widgets for viewport or something like that, which could stay open when you keep on working using normal Blender features). So, if that functionality is not supported, I propose adding some functionality to have some control over "allowed" areas where events could pass through, making Blender UI functional.
I temporarily changed in the code in cookiecutter.py to pass through all events, and it seems to be not breaking any UI interaction, dragging or whatever. So I suppose, some functionality like that can be added in theory without too much pain?
Yes absolitely! we have did this before in 2.79 and decided not to push into master until after the 2.8 upgrade I think. https://github.com/CGCookie/addon_common/tree/pass_through
In this other repository, I have created a "should_pass_through" example (not complete!!) and made alterations to the current cooki_cutter.py
https://github.com/patmo141/cookie_cutter_examples/blob/master/selective_pass_through.py
https://github.com/patmo141/cookie_cutter_examples/blob/master/subtrees/cookiecutter/cookiecutter.py#L157
However I had not thoroughly tested it and wasn't sure exactly where in the cookiecutter modal to insert it. So no merge from me yet. Would love to see what you did.
Thanks for such a quick response! What I did is actually very similar to what you have done in cookiecutter.py with this change, but in a more hacky way. I will test if this change still works properly with action states and if there is no overlapping between events that should pass through.
@skarnproject I just pushed my version of should_pass_through to the addon_common repo
Here is a simple should_pass_through override
def in_region(reg, x, y):
    #first, check outside of area
    if x < reg.x: return False
    if y < reg.y: return False
    if x > reg.x + reg.width: return False
    if y > reg.y + reg.height: return False
     return True
def should_pass_through(self, context, event):
        
 
    if self._hover_ui: return False
    if context.area.type != "VIEW_3D"
        return False
    #first, check outside of area
     outside = False
    if event.mouse_x < context.area.x: outside = True
    if event.mouse_y < context.area.y: outside = True
    if event.mouse_x > context.area.x + context.area.width: outside = True
    if event.mouse_y > context.area.y + context.area.height: outside = True
    
    if outside:
        print('outside the 3DView area')
        return False
     
    #make sure we are in the window region, not the header, tools or UI
    for reg in context.area.regions:
        if in_region(reg, event.mouse_x, event.mouse_y) and reg.type != "WINDOW":
            print('in wrong region')
            return False
        
    return True
After a few more tests and examples I think we will be able to close this feature request