Search in sources :

Example 1 with TouchEventImpl

use of org.kie.workbench.common.stunner.core.client.shape.view.event.TouchEventImpl in project kie-wb-common by kiegroup.

the class ViewEventHandlerManager method registerTouchHandler.

protected HandlerRegistration[] registerTouchHandler(final TouchHandler touchHandler) {
    HandlerRegistration touchStartReg = node.addNodeTouchStartHandler(event -> {
        if (isEnabled()) {
            final TouchEventImpl event1 = buildTouchEvent(event);
            if (null != event1) {
                touchHandler.start(event1);
            }
        }
    });
    HandlerRegistration touchMoveReg = node.addNodeTouchMoveHandler(event -> {
        if (isEnabled()) {
            final TouchEventImpl event1 = buildTouchEvent(event);
            if (null != event1) {
                touchHandler.move(event1);
            }
        }
    });
    HandlerRegistration touchEndReg = node.addNodeTouchEndHandler(event -> {
        if (isEnabled()) {
            final TouchEventImpl event1 = buildTouchEvent(event);
            if (null != event1) {
                touchHandler.end(event1);
            }
        }
    });
    HandlerRegistration touchCancelReg = node.addNodeTouchCancelHandler(event -> {
        if (isEnabled()) {
            final TouchEventImpl event1 = buildTouchEvent(event);
            if (null != event1) {
                touchHandler.cancel(event1);
            }
        }
    });
    return new HandlerRegistration[] { touchStartReg, touchMoveReg, touchEndReg, touchCancelReg };
}
Also used : HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration) TouchEventImpl(org.kie.workbench.common.stunner.core.client.shape.view.event.TouchEventImpl)

Example 2 with TouchEventImpl

use of org.kie.workbench.common.stunner.core.client.shape.view.event.TouchEventImpl in project kie-wb-common by kiegroup.

the class ViewEventHandlerManager method buildTouchEvent.

private TouchEventImpl buildTouchEvent(final AbstractNodeTouchEvent event) {
    final TouchPoint touchPoint = null != event.getTouches() && !event.getTouches().isEmpty() ? (TouchPoint) event.getTouches().get(0) : null;
    if (null != touchPoint) {
        final int tx = touchPoint.getX();
        final int ty = touchPoint.getY();
        return new TouchEventImpl(event.getX(), event.getY(), tx, ty);
    }
    return null;
}
Also used : TouchEventImpl(org.kie.workbench.common.stunner.core.client.shape.view.event.TouchEventImpl) TouchPoint(com.ait.lienzo.client.core.event.TouchPoint) TouchPoint(com.ait.lienzo.client.core.event.TouchPoint)

Aggregations

TouchEventImpl (org.kie.workbench.common.stunner.core.client.shape.view.event.TouchEventImpl)2 TouchPoint (com.ait.lienzo.client.core.event.TouchPoint)1 HandlerRegistration (com.google.gwt.event.shared.HandlerRegistration)1