Scott Lanning > Mozilla-DOM > Mozilla::DOM::DocumentEvent

Download:
Mozilla-DOM-0.23.tar.gz

Annotate this POD

CPAN RT

New  2
Open  5
View/Report Bugs
Source  

NAME ^

Mozilla::DOM::DocumentEvent

DESCRIPTION ^

Mozilla::DOM::DocumentEvent is a wrapper around an instance of Mozilla's nsIDOMDocumentEvent interface. This class inherits from Supports.

 * The nsIDOMDocumentEvent interface is the interface to the event
 * factory method on a DOM document object.
 *
 * For more information on this interface please see
 * L<http:E<sol>E<sol>www.w3.orgE<sol>TRE<sol>DOM-Level-2-EventsE<sol>>

(In particular, sections 1.5 and 1.6. Very important to read that if you want to understand how to create an Event.)

CLASS METHODS ^

$iid = Mozilla::DOM::DocumentEvent->GetIID()

Pass this to QueryInterface on a Document object to get back a DocumentEvent, like

  $window = $browser->GetContentDOMWindow;
  $doc = $window->GetDocument;
  $iid = Mozilla::DOM::DocumentEvent->GetIID
  $docevent = $doc->QueryInterface($iid);
  $event = $docevent->CreateEvent('MouseEvents');
  $event->InitEvent('click', 1, 1);
  ...

You can also print it out, and it will look like

  {46b91d66-28e2-11d4-ab1e-0010830123b4}

METHODS ^

$domevent = $docevent->CreateEvent($eventType)

$event_type is a string, apparently one of 'Events', 'UIEvents', 'HTMLEvents', 'MutationEvents', 'KeyEvents', or 'MouseEvents'. See section 1.6 of the DOM Level 2 specs. Apparently 'KeyEvents' is not in DOM Level 2, but I was able to create them anyway.

The return value is an Event object. You can then call InitEvent. Or you can get the GetIID of UIEvent, MouseEvent, or MouseEvent, pass it to $event->QueryInterface, call the corresponding Init(UI|Mouse|Key)Event method. After that, call DispatchEvent on an EventTarget.

SEE ALSO ^

Mozilla::DOM

COPYRIGHT ^

Copyright (C) 2005-2007, Scott Lanning

This software is licensed under the LGPL. See Mozilla::DOM for a full notice.

syntax highlighting: