platform.touch().onTouchStart(touches); platform.pointer().onPointerStart( new Pointer.Event.Impl(flags, time, pointerEvent.x(), pointerEvent.y(), true)); break; case MotionEvent.ACTION_UP: platform.touch().onTouchEnd(touches); platform.pointer().onPointerEnd( new Pointer.Event.Impl(flags, time, pointerEvent.x(), pointerEvent.y(), true)); break; case MotionEvent.ACTION_POINTER_DOWN: platform.touch().onTouchMove(touches); platform.pointer().onPointerDrag( new Pointer.Event.Impl(flags, time, pointerEvent.x(), pointerEvent.y(), true)); break; case MotionEvent.ACTION_CANCEL: platform.touch().onTouchCancel(touches); platform.pointer().onPointerCancel( new Pointer.Event.Impl(flags, time, pointerEvent.x(), pointerEvent.y(), true)); break;
protected boolean onPointerStart(Event.Impl event, boolean preventDefault) { if (!enabled) return preventDefault; event.flags().setPreventDefault(preventDefault); if (listener != null) { listener.onPointerStart(event); } GroupLayer root = PlayN.graphics().rootLayer(); if (root.interactive()) { Point p = new Point(event.x(), event.y()); root.transform().inverseTransform(p, p); p.x += root.originX(); p.y += root.originY(); active.layer = (AbstractLayer)root.hitTest(p); if (active.layer != null) { event.captureState = active; dispatcher.dispatch(Listener.class, event, START, CANCEL); } } return event.flags().getPreventDefault(); }
platform.touch().onTouchStart(touches); platform.pointer().onPointerStart( new Pointer.Event.Impl(flags, time, pointerEvent.x(), pointerEvent.y(), true)); break; case MotionEvent.ACTION_UP: platform.touch().onTouchEnd(touches); platform.pointer().onPointerEnd( new Pointer.Event.Impl(flags, time, pointerEvent.x(), pointerEvent.y(), true)); break; case MotionEvent.ACTION_POINTER_DOWN: platform.touch().onTouchMove(touches); platform.pointer().onPointerDrag( new Pointer.Event.Impl(flags, time, pointerEvent.x(), pointerEvent.y(), true)); break; case MotionEvent.ACTION_CANCEL: platform.touch().onTouchCancel(touches); platform.pointer().onPointerCancel( new Pointer.Event.Impl(flags, time, pointerEvent.x(), pointerEvent.y(), true)); break;
private Event.Impl toPointerEvent(NSSet<UITouch> touches, UIEvent event) { for (UITouch touch : touches) { long handle = touch.getHandle(); // if we have an active touch, we only care about that touch if (_active == 0 || handle == _active) { _active = handle; CGPoint loc = touch.getLocationInView(touch.getView()); // transform the point based on our current scale IPoint xloc = platform.graphics().transformTouch((float)loc.getX(), (float)loc.getY()); return new Event.Impl( new Events.Flags.Impl(), touch.getTimestamp() * 1000, xloc.x(), xloc.y(), true); } } return null; }
protected boolean onPointerEnd(Event.Impl event, boolean preventDefault) { if (!enabled) return preventDefault; event.flags().setPreventDefault(preventDefault); if (listener != null) { listener.onPointerEnd(event); } if (active.layer != null) { event.captureState = active; dispatcher.dispatch(Listener.class, event, END, null); active.clear(); } return event.flags().getPreventDefault(); }
protected boolean onPointerCancel(Event.Impl event, boolean preventDefault) { if (!enabled) return preventDefault; event.flags().setPreventDefault(preventDefault); if (listener != null) { listener.onPointerCancel(event); } if (active.layer != null) { event.captureState = active; dispatcher.dispatch(Listener.class, event, CANCEL, null); active.clear(); } return event.flags().getPreventDefault(); }
void onMouseDown(double time, float x, float y) { onPointerStart(new Event.Impl(new Events.Flags.Impl(), time, x, y, false), false); mouseDown = true; }
void onMouseDown(double time, float x, float y) { onPointerStart(new Event.Impl(new Events.Flags.Impl(), time, x, y, false), false); mouseDown = true; }
void onMouseUp(double time, float x, float y) { onPointerEnd(new Event.Impl(new Events.Flags.Impl(), time, x, y, false), false); mouseDown = false; }
void onMouseUp(double time, float x, float y) { onPointerEnd(new Event.Impl(new Events.Flags.Impl(), time, x, y, false), false); mouseDown = false; }
private Event.Impl eventFromTouch(final Element rootElement, Touch touch) { float x = touch.getRelativeX(rootElement), y = touch.getRelativeY(rootElement); Point xy = platform.graphics().transformMouse(x, y); return new Event.Impl(new Events.Flags.Impl(), PlayN.currentTime(), xy.x, xy.y, true); } }
@Override public void cancelLayerDrags() { if (active.layer != null) { Event.Impl event = new Event.Impl(new Events.Flags.Impl(), PlayN.currentTime(), 0, 0, false); event.captureState = active; dispatcher.dispatch(Listener.class, event, CANCEL, null); active.clear(); } }
void onMouseMove(double time, float x, float y) { if (mouseDown) { onPointerDrag(new Event.Impl(new Events.Flags.Impl(), time, x, y, false), false); } }
private Event.Impl eventFromMouse(final Element rootElement, NativeEvent nativeEvent) { float x = HtmlInput.getRelativeX(nativeEvent, rootElement); float y = HtmlInput.getRelativeY(nativeEvent, rootElement); Point xy = platform.graphics().transformMouse(x, y); return new Event.Impl(new Events.Flags.Impl(), PlayN.currentTime(), xy.x, xy.y, false); }
void onMouseMove(double time, float x, float y) { if (mouseDown) { onPointerDrag(new Event.Impl(new Events.Flags.Impl(), time, x, y, false), false); } }
protected boolean onPointerDrag(Event.Impl event, boolean preventDefault) { if (!enabled) return preventDefault; event.flags().setPreventDefault(preventDefault); if (listener != null) { listener.onPointerDrag(event); } if (active.layer != null) { event.captureState = active; dispatcher.dispatch(Listener.class, event, DRAG, CANCEL); } return event.flags().getPreventDefault(); }