On Sun, Nov 6, 2011 at 3:35 PM, Edward K. Ream <[email protected]> wrote:
> On Nov 6, 2:20 pm, Kent Tenney <[email protected]> wrote:
>
>> My expectation was for one call per each unselecting of a node. If it's
>> possible to provide that behaviour, it would simplify writing code
>> hooked to the event: as it is, I expect I'll come to the point of needing
>> to keep track of which of the several calls I'm currently in.
>
> Rev 4746 might be what you want.
>
> The selectHelper method is the only method that generates select1/2/3
> and unselect1/2 events.
>
> The new code generates these events only if the newly-requested
> position is not the same as the previous position.
>
> By-hand tests indicate that this works as expected.  I have no idea
> how to do a unit test for this.
>
> All unit tests pass with the new code, which is a non-trivial
> statement, imo.
>
> *Important*: changing tabs or shifting focus from body to headline (or
> anywhere else) has nothing to do with selecting a node: selection
> means something precise, namely that leoTree.select is called, which
> then calls selectHelper.
>
> Let me know how this works for you.  To test the code, I recommend
> setting trace = True; verbose = False in selectHelper.

I don't know what "in selectHelper" means

To test event handlers, I'm using the following which monitors
the selectx and unselectx events

def on_select1(tag, keywords):
    old = keywords['old_p'].h
    new = keywords['new_p'].h
    g.es("select1 %s->%s\n" % (old, new), color="blue")
def on_select2(tag, keywords):
    old = keywords['old_p'].h
    new = keywords['new_p'].h
    g.es("select2 %s->%s\n" % (old, new), color="pink")
def on_select3(tag, keywords):
    old = keywords['old_p'].h
    new = keywords['new_p'].h
    g.es("select3 %s->%s\n" % (old, new), color="green")
def on_unselect1(tag, keywords):
    old = keywords['old_p'].h
    new = keywords['new_p'].h
    g.es("unselect1 %s->%s\n" % (old, new), color="blue")
def on_unselect2(tag, keywords):
    old = keywords['old_p'].h
    new = keywords['new_p'].h
    g.es("unselect2 %s->%s\n" % (old, new), color="pink")

init():
    g.registerHandler("select1", on_select1)
    g.registerHandler("select2", on_select2)
    g.registerHandler("select3", on_select3)
    g.registerHandler("unselect1", on_unselect1)
    g.registerHandler("unselect2", on_unselect2)

and open multiple tabs.
The result is lots and lots of almost random messages.
I'm looking at a window with 28 reps of the select1 message.

I would like to hook code to events allowing me to determine
if a node has been changed, and make appropriate changes
in a database, but at this point I feel like I don't understand
what is going on with event hooking.

For the @session stuff I also wanted to hook to starting up
and closing down Leo, saving and restoring my session.
I was unable to get that working also.

Thanks,
Kent

>
> Edward
>
> --
> You received this message because you are subscribed to the Google Groups 
> "leo-editor" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/leo-editor?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en.

Reply via email to