-
-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Touch Event. Fixes issue #579 #580
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright 2014 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.JSObject; | ||
import org.teavm.jso.JSProperty; | ||
|
||
// From https://developer.mozilla.org/en-US/docs/Web/API/Touch | ||
|
||
public interface Touch extends JSObject { | ||
|
||
@JSProperty | ||
long getIdentifier(); | ||
|
||
@JSProperty | ||
int getScreenX(); | ||
|
||
@JSProperty | ||
int getScreenY(); | ||
|
||
@JSProperty | ||
int getClientX(); | ||
|
||
@JSProperty | ||
int getClientY(); | ||
|
||
@JSProperty | ||
int getPageX(); | ||
|
||
@JSProperty | ||
int getPageY(); | ||
|
||
@JSProperty | ||
EventTarget getTarget(); | ||
|
||
@JSProperty | ||
int getRadiusX(); | ||
|
||
@JSProperty | ||
int getRadiusY(); | ||
|
||
// Not sure if this is an int or a float. This is angle in Degrees | ||
@JSProperty | ||
int getRotationAngle(); | ||
|
||
// between 0.0 (no pressure) and 1.0 (max pressure) | ||
@JSProperty | ||
float getForce(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright 2014 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.JSArray; | ||
|
||
// From https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent | ||
|
||
public interface TouchEvent extends Event { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
|
||
@JSProperty | ||
boolean getCtrlKey(); | ||
|
||
@JSProperty | ||
boolean getShiftKey(); | ||
|
||
@JSProperty | ||
boolean getAltKey(); | ||
|
||
@JSProperty | ||
boolean getMetaKey(); | ||
|
||
@JSProperty | ||
JSArray<Touch> getChangedTouches(); | ||
|
||
@JSProperty | ||
JSArray<Touch> getTargetTouches(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
@JSProperty | ||
JSArray<Touch> getTouches(); | ||
|
||
} |
There was a problem hiding this comment.
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 ifint
fits well or you needdouble
.