diff --git a/jso/apis/src/main/java/org/teavm/jso/browser/WindowEventTarget.java b/jso/apis/src/main/java/org/teavm/jso/browser/WindowEventTarget.java
index 296213a2d..47470e11c 100644
--- a/jso/apis/src/main/java/org/teavm/jso/browser/WindowEventTarget.java
+++ b/jso/apis/src/main/java/org/teavm/jso/browser/WindowEventTarget.java
@@ -27,9 +27,10 @@ import org.teavm.jso.dom.events.MessageEvent;
import org.teavm.jso.dom.events.MouseEventTarget;
import org.teavm.jso.dom.events.Registration;
import org.teavm.jso.dom.events.StorageEvent;
+import org.teavm.jso.dom.events.TouchEventTarget;
public interface WindowEventTarget extends EventTarget, FocusEventTarget, MouseEventTarget, KeyboardEventTarget,
- LoadEventTarget, GamepadEventTarget {
+ LoadEventTarget, GamepadEventTarget, TouchEventTarget {
@Deprecated
default void listenBeforeOnload(EventListener
The {@link #getRadiusX()}, {@link #getRadiusY()}, and {@link #getRotationAngle()} + * describe the area of contact between the user and the screen, the touch area. + * This can be helpful when dealing with imprecise pointing devices such as fingers. + * These values are set to describe an ellipse that as closely as possible matches + * the entire area of contact (such as the user's fingertip).
+ */ +public interface Touch extends JSObject { + /** + * Returns a unique identifier for this Touch object. A given touch point (say, + * by a finger) will have the same identifier for the duration of its movement + * around the surface. This lets you ensure that you're tracking the same touch + * all the time. + */ + @JSProperty + int getIdentifier(); + + /** + * Returns the X coordinate of the touch point relative to the left edge of the + * screen. + */ + @JSProperty + double getScreenX(); + + /** + * Returns the Y coordinate of the touch point relative to the top edge of the + * screen. + */ + @JSProperty + double getScreenY(); + + /** + * Returns the X coordinate of the touch point relative to the left edge of the + * browser viewport, not including any scroll offset. + */ + @JSProperty + double getClientX(); + + /** + * Returns the Y coordinate of the touch point relative to the top edge of the + * browser viewport, not including any scroll offset. + */ + @JSProperty + double getClientY(); + + /** + * Returns the X coordinate of the touch point relative to the left edge of the + * document. Unlike clientX, this value includes the horizontal scroll offset, + * if any. + */ + @JSProperty + double getPageX(); + + /** + * Returns the Y coordinate of the touch point relative to the top of the + * document. Unlike clientY, this value includes the vertical scroll offset, if + * any. + */ + @JSProperty + double getPageY(); + + /** + * Returns the {@link TouchEventTarget} on which the touch point started when it was first placed + * on the surface, even if the touch point has since moved outside the + * interactive area of that element or even been removed from the document. + */ + @JSProperty + TouchEventTarget getTarget(); + + /** + * Returns the X radius of the ellipse that most closely circumscribes the area + * of contact with the screen. The value is in pixels of the same scale as + * screenX. + */ + @JSProperty + double getRadiusX(); + + /** + * Returns the Y radius of the ellipse that most closely circumscribes the area + * of contact with the screen. The value is in pixels of the same scale as + * screenY. + */ + @JSProperty + double getRadiusY(); + + /** + * Returns the angle (in degrees) that the ellipse described by radiusX and + * radiusY must be rotated, clockwise, to most accurately cover the area of + * contact between the user and the surface. + */ + @JSProperty + double getRotationAngle(); + + /** + * Returns the amount of pressure being applied to the surface by the user, as a + * float between 0.0 (no pressure) and 1.0 (maximum pressure). + */ + @JSProperty + double getForce(); +} \ No newline at end of file diff --git a/jso/apis/src/main/java/org/teavm/jso/dom/events/TouchEvent.java b/jso/apis/src/main/java/org/teavm/jso/dom/events/TouchEvent.java new file mode 100644 index 000000000..05e28db88 --- /dev/null +++ b/jso/apis/src/main/java/org/teavm/jso/dom/events/TouchEvent.java @@ -0,0 +1,81 @@ +/* + * Copyright 2024 pizzadox9999, Alexey Andreev. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.teavm.jso.dom.events; + +import org.teavm.jso.JSProperty; +import org.teavm.jso.core.JSArrayReader; + +/** + * The TouchEvent interface represents an UIEvent which is sent when the state + * of contacts with a touch-sensitive surface changes. + * This surface can be a touch screen or trackpad, for example. + * The event can describe one or more points of contact with the screen and includes support + * for detecting movement, addition and removal of contact points, and so forth. + * + *Touches are represented by the {@link Touch} object; each touch is described by a position, + * size and shape, amount of pressure, and target element.
+ */ +public interface TouchEvent extends Event { + /** + * A {@code boolean} value indicating whether the alt key was down when the touch + * event was fired. + */ + @JSProperty + boolean isAltKey(); + + /** + * A list of all the {@link Touch} objects representing individual points of + * contact whose states changed between the previous touch event and this one. + */ + @JSProperty + JSArrayReaderThe touchcancel event is fired when one or more touch points have been disrupted in an + * implementation-specific manner.
+ * + *Some examples of situations that will trigger a touchcancel event:
+ * + *