[Bf-committers] Request for spacehandler patch

steven admin at byteshelter.org
Tue Apr 15 16:04:20 CEST 2008

        i'm currently implementing an object orientated python gui api
        script developers to make it easier to write gui elements.
        I had the problem that for spacehandler event scripts, there is
        Blender.event, so it differes with the way a gui script handles
        handle(event, value)
        The only thing i changed is the BPY_do_spacehandler function to
        get also
        the value passed. I've created the patch with latest svn and
        tested it.
        I found no problems until now.
        I don't know how good/bad it was to do this, but it makes the
        gui api
        able to also catch events for spacehandlers the same way it does
        for the
        script window, and that makes the gui realy much faster. To rely
        on the
        window module to get those values is realllyyyy slow.
        Here an example spacehandler:
        from Blender.event import event as ev
        from Blender.eventValue import eventValue as val
        print "Event: [%i, %i]", ev, val
        and here the patch: 
        Index: source/blender/python/BPY_extern.h
        --- source/blender/python/BPY_extern.h  (Revision 14428)
        +++ source/blender/python/BPY_extern.h  (Arbeitskopie)
        @@ -111,6 +111,7 @@
                int BPY_has_spacehandler(struct Text *text, struct
        ScrArea *sa);
                void BPY_screen_free_spacehandlers(struct bScreen *sc);
                int BPY_do_spacehandlers(struct ScrArea *sa, unsigned
        short event,
        +               unsigned short eventValue,
                        unsigned short space_event);
                void BPY_pydriver_update(void);
        Index: source/blender/python/BPY_interface.c
        --- source/blender/python/BPY_interface.c       (Revision 14428)
        +++ source/blender/python/BPY_interface.c       (Arbeitskopie)
        @@ -2450,6 +2450,7 @@
         int BPY_do_spacehandlers( ScrArea *sa, unsigned short event,
        +       unsigned short eventValue,
                unsigned short space_event )
                ScriptLink *scriptlink;
        @@ -2492,6 +2493,8 @@
                        EXPP_dict_set_item_str(g_blenderdict, "link",
                        /* note: DRAW space_events set event to 0 */
                        EXPP_dict_set_item_str(g_blenderdict, "event",
        +               /* to make spacehandler event script similar to
        gui event handlers */
        +               EXPP_dict_set_item_str(g_blenderdict,
                        /* now run all assigned space handlers for this
        space and space_event
                        for( index = 0; index < scriptlink->totscript;
        index++ ) {
        Index: source/blender/src/drawview.c
        --- source/blender/src/drawview.c       (Revision 14428)
        +++ source/blender/src/drawview.c       (Arbeitskopie)
        @@ -3254,7 +3254,7 @@
                /* run any view3d draw handler script links */
                if (sa->scriptlink.totscript)
        -               BPY_do_spacehandlers(sa, 0,
        +               BPY_do_spacehandlers(sa, 0, 0,
                /* run scene redraw script links */
                if((G.f & G_DOSCRIPTLINKS) &&
        G.scene->scriptlink.totscript &&
        Index: source/blender/src/space.c
        --- source/blender/src/space.c  (Revision 14428)
        +++ source/blender/src/space.c  (Arbeitskopie)
        @@ -1247,7 +1247,7 @@
                        /* run any view3d event handler script links */
                        if (event && sa->scriptlink.totscript)
        -                       if (BPY_do_spacehandlers(sa, event,
        +                       if (BPY_do_spacehandlers(sa, event, val,
                                        return; /* return if event was
        processed (swallowed) by handler(s)
                        /* TEXTEDITING?? */
        best regards,
        Steven Truppe

More information about the Bf-committers mailing list