W3C home > Mailing lists > Public > www-dom@w3.org > July to September 2009

Re: Detecting and Creating Events

From: Olli Pettay <Olli.Pettay@helsinki.fi>
Date: Thu, 20 Aug 2009 15:13:46 +0300
Message-ID: <4A8D3DFA.40905@helsinki.fi>
To: Garrett Smith <dhtmlkitchen@gmail.com>
CC: DOM mailing list <www-dom@w3.org>
On 8/20/09 8:18 AM, Garrett Smith wrote:
> The inability to easily and accurately detect events is a problem.
> Programs want to know if an event is implemented at runtime. If it is,
> then the feature can be used. If not, it a fallback stratety is in
> order. Many new event types are being created and implemented. How can
> a program feature-test to see if they are implemented?
>
> Proposal: add a "hasEvent" method to EventTarget:
>
> EventTarget {
>    boolean hasEvent(in DOMString eventType)
> }
>
> This allows script to call the target's "hasEvent" method to see if
> the event is (claimed to be) supported.
>
> var hasFocusIn = false;
>
> if(typeof el.hasEvent != "undefined") {
>    hasFocusIn = el.hasEvent("domfocusin");
> }
>
This has the problem that browser may not know what additional events
extensions or plugins can fire.


> There should be a simple way to create and fire an event.
>
> interface DocumentEvent {
>    Event createInitedEvent(in domstring type, in Object options)
>    raises(dom::DOMException);
> }
>
> In createInitedEvent, the type of event created is determined by the
> string arg /type/, which is a prefixed with a DOM Interface (as a
> string) followed by ".", followed by the event type. The event is
> inited with the /options/. This is a "map" of options that the event
> has, such as - offsetX - , - pageY - , etc.
I agree a method like this would be very useful, but it could
be easily implemented in a script library.

It could be useful to have
dispatchInitedEvent(in domstring type, in Object options)
in EventTarget. (again something to implement easily in a script library)


-Olli
Received on Thursday, 20 August 2009 12:14:25 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:14:03 GMT