mmmrqs / bl_ui_widgets

UI Widgets for Blender 2.8 and newer versions
GNU General Public License v3.0
46 stars 5 forks source link

[BUG] the button mouse up binding will not pass the context to the function #14

Closed atticus-lv closed 1 year ago

atticus-lv commented 1 year ago

The origin repo do not have this problem Try binding this with the mouse up function (Even using the context overide will not fix this problem)

def btn_click(self,widget,event,x,y):
    bpy.ops.view3d.view_axis(type = 'TOP')
atticus-lv commented 1 year ago

@mmmrqs hey mmmrqs do you have time to check this issue?

mmmrqs commented 1 year ago

Hi. I still need to check it out. Haven't had spare time recently. Thanks for your contribution, that's much appreciated.

Em sex, 19 de mai de 2023 12:54, atticus-lv @.***> escreveu:

@mmmrqs https://github.com/mmmrqs hey mmmrqs do you have time to check this issue?

— Reply to this email directly, view it on GitHub https://github.com/mmmrqs/bl_ui_widgets/issues/14#issuecomment-1554783105, or unsubscribe https://github.com/notifications/unsubscribe-auth/AU7ZZUH4IQBVEMDWCAJCSNLXG6JRZANCNFSM6AAAAAAYBXWXKU . You are receiving this because you were mentioned.Message ID: @.***>

mmmrqs commented 1 year ago

The origin repo do not have this problem Try binding this with the mouse up function (Even using the context overide will not fix this problem)

def btn_click(self,widget,event,x,y):
    bpy.ops.view3d.view_axis(type = 'TOP')

Hi @atticus-lv, this is kind of annoying issue and such a complicated one. I was able to find a workaround though, using context override with some tweaks. I confess that I do not have much expertise with these Blender/Python idiosyncrasies but this solution works fine for this particular case. You may want to try the following example:

def btn_click(self, widget, event, x, y):
    for window in bpy.context.window_manager.windows:
        for area in window.screen.areas:
            if area.type == 'VIEW_3D':
                with bpy.context.temp_override(window=window, area=area, region=area.regions[-1]):
                    bpy.ops.view3d.view_axis(type = 'TOP')
                return True

I am going to update the code in my repo with all these changes and the sample piece will be there for people to refer. Once again, thank you very much for bringing this to my attention. I apologize for not having time to provide a quicker support, but it is what it is.