393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
|
# File 'lib/fzeet/windows/mshtml/Common.rb', line 393
def on(event, &block)
((@handlers ||= {})[event] ||= []) << block
@dcallbacks ||= []
send("put_on#{event}", VARIANT.new.tap { |v|
v[:vt] = VT_DISPATCH
v[:pdispVal] = @dcallbacks.push(DCallback.new.tap { |dcb|
dcb.instance_variable_set(:@window, self)
dcb.instance_variable_set(:@event, event)
def dcb.Invoke(*args)
@window.handlers[@event].each { |handler|
(handler.arity == 0) ? handler.call : handler.call(*args)
}
S_OK
end
}).last
}) unless @handlers[event].length > 1
self
end
|