[Tk] Bug on TkBindTag.new_by_name ?

  • Thread starter email55555 email55555
  • Start date
E

email55555 email55555

It seems to me that there is a bug on TkBindTag.new_by_name.
Here is an example:

# The action on new_by_name has no effect ?! bug ?
require 'tk'
TkBindTag.new_by_name('My_BindTag', 'Button') {|e| puts 'OK'}
TkLabel.new:)text=>:Test).pack.bindtags = ['My_BandTag']
Tk.mainloop

However, this works:
require 'tk'
b = TkBindTag.new_by_name('My_BindTag')
b.bind('Button') {|e| puts 'OK'}
TkLabel.new:)text=>:Test).pack.bindtags = ['My_BandTag']
Tk.mainloop

By looking on the source code of TkBindTag, it seems on the new_by_name:
BTagID_TBL.delete @id ==> also delete the old action
the new one just has its name but no action associate to it.
That is maybe why the new_by_name action has no effect.
This seems a bug ?

Thanks.
 
H

Hidetoshi NAGAI

Hi,

From: email55555 email55555 <[email protected]>
Subject: [Tk] Bug on TkBindTag.new_by_name ?
Date: Wed, 15 Dec 2004 10:02:11 +0900
Message-ID: said:
It seems to me that there is a bug on TkBindTag.new_by_name.
Here is an example: (snip)
This seems a bug ?

Yes. You are right.
Please replace TkBindTag.new_by_name to the following.
-----------------------------------------------------
def TkBindTag.new_by_name(name, *args, &b)
return BTagID_TBL[name] if BTagID_TBL[name]
self.new.instance_eval{
BTagID_TBL.delete @id
@id = name
BTagID_TBL[@id] = self
bind(*args, &b) if args != []
}
end
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top