I’ve tried to boil this down to be as meaningful as possible. I’m
guessing this is a Tk issue, but since I’m using Ruby (1.8.0) I thought
I’d start here.
Type any English text character into the entry box, and the target proc
sees the character as typed (e.g. type an a and it sees an “a”, type a b
and it sees the field contains “ab”).
The exception is the “{” (left brace). Type one in and the entry box has
one “{”, but The TkVariable @myText displays it as empty (the TkComm
object sees that as an escaped character “{” ). Type a second left
brace and the entry field has 2 braces and the TkVariable @myText still
extracts an empty string.
Type a 3rd brace and now the @myText.to_s gives back 1 brace (all of
them right of the first 2?).
Thanks for any insight.
Mac
require ‘tk’;
def puts_KeyChar(tkcommObj);
puts ‘key release - ’ + tkcommObj.char() + ’ -’;
puts ‘entry variable - ’ + @myText.to_s + ’ -’;
end
myWindowRoot = TkRoot.new {title ‘Tk Test’};
@myText = TkVariable.new(’’);
myEntry = TkEntry.new(myWindowRoot);
myEntry.textvariable(@myText);
myEntry.pack(‘side’=>‘top’);
myEntry.bind(‘Any-KeyRelease’,proc {|tkcommObj| puts_KeyChar(tkcommObj)});
Tk.mainloop;