Skip to content

Add Touch Event. Fixes issue #579#580

Open
coder111111 wants to merge 1 commit intokonsoletyper:masterfrom
coder111111:master
Open

Add Touch Event. Fixes issue #579#580
coder111111 wants to merge 1 commit intokonsoletyper:masterfrom
coder111111:master

Conversation

@coder111111
Copy link

Hi,

I wanted to play with touch events today, so I added them myself. Please review code and merge upstream if you like it.

--Coder

public interface Touch extends JSObject {

@JSProperty
long getIdentifier();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work. JavaScript does not provide int64 type (or at least, did not provide by the time touch event spec was written). I'd replaced this with int, but you should test on real use cases if int fits well or you need double.


// From https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent

public interface TouchEvent extends Event {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, you created an event class. But how one's to use it. What about declaring corresponding event target interface, like I did it with MouseEventTarget, for example?

JSArray<Touch> getChangedTouches();

@JSProperty
JSArray<Touch> getTargetTouches();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Is it really necessary to expose this property as JSArray? What about just Touch[]?
  2. If you still want JS native type, consider JSArrayReader<Touch> here

Ihromant added a commit to Ihromant/teavm that referenced this pull request Nov 23, 2023
@Ihromant
Copy link
Contributor

This PR can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants