handler=

WIN32OLE_EVENT#handler=
Instance Public methods

sets event handler object. If handler object has onXXX method according to XXX event, then onXXX method is called when XXX event occurs.

If handler object has method_missing and there is no method according to the event, then method_missing called and 1-st argument is event name.

If handler object has onXXX method and there is block defined by #on_event('XXX'){}, then block is executed but handler object method is not called when XXX event occurs.

class Handler
  def onStatusTextChange(text)
    puts "StatusTextChanged"
  end
  def onPropertyChange(prop)
    puts "PropertyChanged"
  end
  def method_missing(ev, *arg)
    puts "other event #{ev}"
  end
end

handler = Handler.new
ie = WIN32OLE.new('InternetExplorer.Application')
ev = WIN32OLE_EVENT.new(ie)
ev.on_event("StatusTextChange") {|*args|
  puts "this block executed."
  puts "handler.onStatusTextChange method is not called."
}
ev.handler = handler
doc_ruby_on_rails
2015-06-12 22:27:18
Comments
Leave a Comment

Please login to continue.