Re: this problem makes my head hurt...
Brian Denheyer writes:
>
> I ran into the following situation and I can't think of a clean way to
> get around it...
>
> Let's say there is proc A. When procedure A is invoked, let's say by a
> menu entry, proc A makes some new event bindings and then invokes a
> tkwait.
>
> Like this :
>
> (define A
> (lambda ()
> (bind ...)
> (bind ...)
> (tkwait 'variable 'done)
> ;; cleanup...))
>
> *however* activity at the top level continues.
I'm really not sure to understand what you try to do, so perhaps I'm
not answering to your problem. Anyway, I'll try.
Perhaps you coud use grab her if you want to avoid the activity on
other windows.
> Let's say that some
> other menu entry then causes proc B to be executed which does
> something similar :
>
> (define B
> (lambda ()
> (bind ...)
> (bind ...)
> (tkwait 'variable 'done)
> ;; cleanup...))
>
> So now the problem. Porc A's bindings are still in effect. So, for
> instance, if key-K was bound in proc A, and proc B is "executing",
> control will return to proc A and the action bound there will be
> invoked. What I realy want is for a change in "mode" to abort A.
>
> One can then imagine that there are many routines like this, each of which should be aborted if another routine is invoked.
>
> The best thing I have thought of so far is to make DONE a global
> variable so that the top-level can set it's value causing porc A's
> cleanup to be invoked. The problem is thatyou really want to know
> that proc A has finished clean-up before invoking B. So now I am
> thinking semaphore sorts of operations and it seems to me like this is
> getting more complicated than it really should be.
>
> Any suggestions...
Here again, I'm not usre to understand.... But this is surely not a
reason for not giving my opinion ;-)
Try to finish your binding with 'break to avoid the execution of
further bindinds.
For instance
(pack (label '.l :text "TEST"))
(focus .l)
(bind "Label" "<KeyPress>" (lambda () (display "Key") (newline)))
(bind .l "<x>" (lambda () (display "x pressed") (newline)))
Here, pressing a x causes the printing of two messages. Changing
the second bind to
(bind .l "<x>" (lambda () (display "x pressed") (newline) 'break))
Perhaps "bindtags" can be also your friend. It allows you to change the
order of bindings to what you want. What is interesting with bindtags,
is that you can introduce virtual classes name in the bindings chain.
An example is provided in the man page.
Hope it helps.
-- Erick
Received on Sun Nov 08 1998 - 20:20:55 CET
This archive was generated by hypermail 2.3.0
: Mon Jul 21 2014 - 19:38:59 CEST