From 28056310252aba112b991f13efcc8db0025f3f87 Mon Sep 17 00:00:00 2001 From: Ivan Hetman Date: Wed, 14 Aug 2024 15:48:21 +0300 Subject: [PATCH] jso: add InputEvent (#902) --- .../org/teavm/jso/dom/events/InputEvent.java | 26 +++++++++++++++++++ .../jso/dom/events/InputEventTarget.java | 22 ++++++++++++++++ .../org/teavm/jso/dom/events/MouseEvent.java | 3 +++ .../org/teavm/jso/dom/html/HTMLElement.java | 4 ++- 4 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 jso/apis/src/main/java/org/teavm/jso/dom/events/InputEvent.java create mode 100644 jso/apis/src/main/java/org/teavm/jso/dom/events/InputEventTarget.java diff --git a/jso/apis/src/main/java/org/teavm/jso/dom/events/InputEvent.java b/jso/apis/src/main/java/org/teavm/jso/dom/events/InputEvent.java new file mode 100644 index 000000000..4ff3c55a9 --- /dev/null +++ b/jso/apis/src/main/java/org/teavm/jso/dom/events/InputEvent.java @@ -0,0 +1,26 @@ +/* + * Copyright 2024 ihromant. + * + * 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; + +public interface InputEvent extends Event { + @JSProperty + String getData(); + + @JSProperty + String getInputType(); +} diff --git a/jso/apis/src/main/java/org/teavm/jso/dom/events/InputEventTarget.java b/jso/apis/src/main/java/org/teavm/jso/dom/events/InputEventTarget.java new file mode 100644 index 000000000..b4228d21b --- /dev/null +++ b/jso/apis/src/main/java/org/teavm/jso/dom/events/InputEventTarget.java @@ -0,0 +1,22 @@ +/* + * Copyright 2024 ihromant. + * + * 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; + +public interface InputEventTarget extends EventTarget { + default Registration onInput(EventListener listener) { + return onEvent("input", listener); + } +} diff --git a/jso/apis/src/main/java/org/teavm/jso/dom/events/MouseEvent.java b/jso/apis/src/main/java/org/teavm/jso/dom/events/MouseEvent.java index 7b8efa2ef..f29710968 100644 --- a/jso/apis/src/main/java/org/teavm/jso/dom/events/MouseEvent.java +++ b/jso/apis/src/main/java/org/teavm/jso/dom/events/MouseEvent.java @@ -80,6 +80,9 @@ public interface MouseEvent extends Event { @JSProperty double getMovementY(); + @JSProperty + int getDetail(); + void initMouseEvent(String type, boolean canBubble, boolean cancelable, JSObject view, int detail, int screenX, int screenY, int clientX, int clientY, boolean ctrlKey, boolean altKey, boolean shiftKey, boolean metaKey, short button, EventTarget relatedTarget); diff --git a/jso/apis/src/main/java/org/teavm/jso/dom/html/HTMLElement.java b/jso/apis/src/main/java/org/teavm/jso/dom/html/HTMLElement.java index df41315e5..440b02b76 100644 --- a/jso/apis/src/main/java/org/teavm/jso/dom/html/HTMLElement.java +++ b/jso/apis/src/main/java/org/teavm/jso/dom/html/HTMLElement.java @@ -20,6 +20,7 @@ import org.teavm.jso.JSProperty; import org.teavm.jso.dom.css.ElementCSSInlineStyle; import org.teavm.jso.dom.events.EventTarget; import org.teavm.jso.dom.events.FocusEventTarget; +import org.teavm.jso.dom.events.InputEventTarget; import org.teavm.jso.dom.events.KeyboardEventTarget; import org.teavm.jso.dom.events.LoadEventTarget; import org.teavm.jso.dom.events.MouseEventTarget; @@ -32,7 +33,8 @@ import org.teavm.jso.dom.xml.NodeList; import org.teavm.jso.popover.ToggleEventTarget; public abstract class HTMLElement implements Element, ElementCSSInlineStyle, EventTarget, FocusEventTarget, - MouseEventTarget, WheelEventTarget, KeyboardEventTarget, LoadEventTarget, TouchEventTarget, ToggleEventTarget { + MouseEventTarget, WheelEventTarget, KeyboardEventTarget, LoadEventTarget, TouchEventTarget, ToggleEventTarget, + InputEventTarget { @Override public abstract NodeList getElementsByTagName(String name);