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 };
}
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;
}
Aggregations