Hi all,
I am getting inside tcltk.rb. I have a question with callbacks: how can
I pass parameters to a non-bind callback? E.g., I have a proc which can
handle many button’s click if I could pass a parameter that which button
was pressed (for example). And I do not want to write as many procs as
many buttons I have. It would be the best if I do not need to write as
many callbacks either, i.e., I could pass the parameters where I create
the button widget.
Unfortunately, I cannot pass parameters to the callback, as (because of
bind) the ‘%s’ in the 1st arg of ruby_fmt is replaced with %%s. And the
(proper) ‘%s’ is put only when there are no parameters (I do not
understand why).
The relevant code from tcltk.rb (class TclTkCallback):
def to_eval()
if @arg
# bind replaces %s before calling ruby_fmt, so %%s is used
s = %Q/{ruby_fmt {TclTk._callcallback("#{to_s()}", “%%s”)}
#{@arg}}/
else
s = %Q/{ruby_fmt {TclTk._callcallback("#{to_s()}", “%s”)}}/
end
return s
end
Is it impossible what I want to do, or do I miss something?
Thanks:
Circum