// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. part of $LIBRARYNAME; $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS { factory $CLASSNAME(String type, {Window$NULLABLE view, int detail: 0, int screenX: 0, int screenY: 0, int clientX: 0, int clientY: 0, int button: 0, bool canBubble: true, bool cancelable: true, bool ctrlKey: false, bool altKey: false, bool shiftKey: false, bool metaKey: false, EventTarget$NULLABLE relatedTarget}) { if (view == null) { view = window; } MouseEvent event = document._createEvent('MouseEvent') $#NULLSAFECAST(as MouseEvent); event._initMouseEvent(type, canBubble, cancelable, view, detail, screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget); return event; } $!MEMBERS Point get client => new Point(_clientX, _clientY); @SupportedBrowser(SupportedBrowser.CHROME) @SupportedBrowser(SupportedBrowser.FIREFOX) Point get movement => new Point(_movementX$NULLASSERT, _movementY$NULLASSERT); /** * The coordinates of the mouse pointer in target node coordinates. * * This value may vary between platforms if the target node moves * after the event has fired or if the element has CSS transforms affecting * it. */ Point get offset { if (JS('bool', '!!#.offsetX', this)) { var x = JS('int', '#.offsetX', this); var y = JS('int', '#.offsetY', this); return new Point(x $#NULLSAFECAST(as num), y $#NULLSAFECAST(as num)); } else { // Firefox does not support offsetX. if (!(this.target is Element)) { throw new UnsupportedError( 'offsetX is only supported on elements'); } Element target = this.target $#NULLSAFECAST(as Element); var point = (this.client - target.getBoundingClientRect().topLeft); return new Point(point.x.toInt(), point.y.toInt()); } } Point get screen => new Point(_screenX, _screenY); Point get layer => new Point(_layerX$NULLASSERT, _layerY$NULLASSERT); Point get page => new Point(_pageX$NULLASSERT, _pageY$NULLASSERT); DataTransfer get dataTransfer => JS('DataTransfer', "#['dataTransfer']", this); }