# # tk/bind.rb : control event binding # require 'tk' class TkBindTag include TkBindCore #BTagID_TBL = {} BTagID_TBL = TkCore::INTERP.create_table Tk_BINDTAG_ID = ["btag".freeze, "00000".taint].freeze TkCore::INTERP.init_ip_env{ BTagID_TBL.clear } def TkBindTag.id2obj(id) BTagID_TBL[id]? BTagID_TBL[id]: id end 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 != [] self } end def initialize(*args, &b) # @id = Tk_BINDTAG_ID.join('') @id = Tk_BINDTAG_ID.join(TkCore::INTERP._ip_id_) Tk_BINDTAG_ID[1].succ! BTagID_TBL[@id] = self bind(*args, &b) if args != [] end ALL = self.new_by_name('all') def name @id end def to_eval @id end def inspect #Kernel.format "#", @id '#' end end class TkBindTagAll", @id '#' end end