You're right that widget.bind('Key-Up') {|e| aCallback(e)} is the
standard way of doing a callback in Ruby/Tk. However, how would
you do it if you needed to reference the callback in some place
other than the widget.bind?
In the Perl/Tk book the DoWhenIdle is defined as:
$widget->DoWhenIdle(callback);
Queues callback in the low priority idle event queue.
Then:
$widget->idleTasks;
Flushes the low priority idle event queue.
This seemed worth a try as a means of discarding the flood of
callbacks generated by a repeating key. However, it is probably
moot in that Ruby/Tk apparently does not have a DoWhenIdle nor a
idleTasks method. With such poor documentation, one is left with
just poking at a black box to see what happens. Slow going.
The main reason for all of this is that Tk is so slow. But, it
is also so easy to use.
Catch-22.
Kero van Gelder wrote:
>
> > How might I name a block and then use it the widget.bind and
> > widget.DoWhenIdle, i.e.
> >
> > aProc = proc{|e| aCallback(e)}
> > <more>
> > widget.bind('Key-Up') &aProc
> > <more>
> > widget.DoWhenIdle(&aProc)
> > <more>
> > widget.idleTasks
> >
> > I have tried several variations, but can't get past the
> > widget.bind. I must have a really wrong model of this in my
> > head.
>
> widget.bind('Key-Up') { |e|
> aCallback(e)
> }
>
> doing it with aProc is a bit cumbersome:
>
> aProc = proc {
> aCallback(e)
> }
> widget.bind('Key-Up') { |e|
> aProc.call(e)
> }
>
> PS: what's with idle? idle means doing nothing, yet you seem to let
> the widget do something...
>
> +--- Kero ------------------------------ kero / chello.nl ---+
> | Don't split your mentality without thinking twice |
> | Proud like a God -- Guano Apes |
> +--- M38c ------- http://members.chello.nl/~k.vangelder ---+
--
"It requires wisdom to understand wisdom:
the music is nothing if the audience is deaf."
- Walter Lippman