Class: Fzeet::Windows::HTMLWindow6

Inherits:
Object
  • Object
show all
Defined in:
lib/fzeet/windows/mshtml/Common.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#handlersObject (readonly)

Returns the value of attribute handlers.



391
392
393
# File 'lib/fzeet/windows/mshtml/Common.rb', line 391

def handlers
  @handlers
end

Instance Method Details

#on(event, &block) ⇒ Object



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