Take_tk
ggb03****@nifty*****
Thu Oct 24 01:15:18 JST 2002
Hi! This is take_tk. FROM [ap-dev:0479] ap-633b Late assignment of Delphi event handlers Fri, 10 May 2002 In order to improve execution speed, Apollo-633b or later version adopted a "late assignment of Delphi event handlers". * In current version, the structure is implemented in "C:/Program Files/Apollo/bin/phi.rb" as follows; -- module Phi EventHandle = {} class Persistent private def singleton_method_added(id) p [:s, id] if $DEBUG return unless self.respond_to? :event_handle case id.to_s when /^on_/, /^after_/, /^before_/ self.event_handle id end end def Persistent.method_added(id) p [:m, id] if $DEBUG case id.to_s when /^on_/, /^after_/, /^before_/ if EventHandle[self].nil? EventHandle[self] = [] end EventHandle[self].push id end end ... def initialize(*args) super(*args) if EventHandle[type] EventHandle[type].each do|id| begin event_handle id rescue DelphiError # end end end end end end ---- This means, when "initialize" method is defined in a inherited class, if it does not carry out "super", Persistent#initialize is no longer called. Therefore, event handlers are no longer initialized. Mr. "repeater" reported following phenomenon; In the following program, on_click handler is not work, if "super" is comment-outed in the definition of "initialize" method. -- #! ruby -Ks require "phi" class MyPanel < Phi::Panel def on_click p "MyPanel#on_click" end def initialize( *args ) #super( *args ) #<= uncomment this to make test work. why ? end end form = Phi::Form.new MyPanel.new form form.show Phi.mainloop -- How to succeed is under examination even if there is no continuation of "super". --- I don't know whether this relates, but Mr. Sakurai reported that Ruby version 1.6.6 does not work well but 1.6.7 or more well. [ap-dev:0491] take_tk = kumagai hidetake