[plt-scheme] event binding help
>>>>> "Bruce" == Bruce Hauman <bhauman at cs.wcu.edu> writes:
Bruce> For list-related administrative tasks:
Bruce> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
Bruce> Hey Brian,
Bruce> There are many ways to do what you are asking. Here is some
Bruce> code that only implements two different ways. One uses the
Bruce> event delegation model that Java uses heavily in its GUI API.
Bruce> The other just uses straight mutation of the button's
Bruce> callback.
Bruce> I would advise against making a bunch of global event
Bruce> handlers. It would really be good to find the lowest points
Bruce> on the event chain and introduce your handlers there.
Thanks for the example Bruce.
I think I found a more succinct way of expressing what I'm trying to do.
Given the way the event-handling currently works, with keypresses and
mouse-events being separate methods (or even if they aren't), the code
ends up looking like :
event-keypress
state=line do...
state=circle do...
later in the code...
event-mouse-motion
state=in-line do
state=in-circle do
even-mouse-button
state=in-line do
state=in-circle do
etc...
This breaks up the "tool" operation through several points in the
code, which is not useful.
What I want is the "inverse" of the above, i.e.
state=in-line
event=button-down do...
event=motion do ...
event=key-press do...
The bind methodology makes for code which is much easier to
understand, i.e. the 2nd form. I was hoping that the eventspace
functionality would allow me to do something similar, but if it does I
can't figure it out.
I believe that the "java-like" portion of your example demonstrates
that this functionality must be explicitly provided.
Thank you for your help.
Brian