Example usage for com.google.gwt.dom.client BrowserEvents TOUCHSTART

List of usage examples for com.google.gwt.dom.client BrowserEvents TOUCHSTART

Introduction

In this page you can find the example usage for com.google.gwt.dom.client BrowserEvents TOUCHSTART.

Prototype

String TOUCHSTART

To view the source code for com.google.gwt.dom.client BrowserEvents TOUCHSTART.

Click Source Link

Usage

From source file:com.sencha.gxt.cell.core.client.AbstractEventCell.java

License:sencha.com license

public void addCellGestureAdapter(CellGestureAdapter<? extends GestureRecognizer, C> cellGestureAdapter) {
    if (cellGestureAdapters == null) {
        cellGestureAdapters = new ArrayList<CellGestureAdapter<? extends GestureRecognizer, C>>();
        Set<String> updated = new HashSet<String>();
        Set<String> consumedEvents = super.getConsumedEvents();
        if (consumedEvents != null) {
            updated.addAll(consumedEvents);
        }/*from  w  ww  . ja v a2 s  .  c  om*/
        if (PointerEventsSupport.impl.isSupported()) {
            updated.add(PointerEvents.POINTERDOWN.getEventName());
            updated.add(PointerEvents.POINTERMOVE.getEventName());
            updated.add(PointerEvents.POINTERUP.getEventName());
            updated.add(PointerEvents.POINTERCANCEL.getEventName());
        }
        updated.add(BrowserEvents.TOUCHSTART);
        updated.add(BrowserEvents.TOUCHMOVE);
        updated.add(BrowserEvents.TOUCHCANCEL);
        updated.add(BrowserEvents.TOUCHEND);
        setConsumedEventsInternal(Collections.unmodifiableSet(updated));
    }
    cellGestureAdapter.setDelegate(this);
    cellGestureAdapters.add(cellGestureAdapter);
}

From source file:com.sencha.gxt.cell.core.client.AbstractEventCell.java

License:sencha.com license

@Override
public void onBrowserEvent(Context context, Element parent, C value, NativeEvent event,
        ValueUpdater<C> valueUpdater) {
    super.onBrowserEvent(context, parent, value, event, valueUpdater);
    String eventType = event.getType();
    if (BrowserEvents.TOUCHSTART.equals(eventType) || BrowserEvents.TOUCHMOVE.equals(eventType)
            || BrowserEvents.TOUCHCANCEL.equals(eventType) || BrowserEvents.TOUCHEND.equals(eventType)) {
        onTouch(context, parent, value, event, valueUpdater);
    }/*from   w  ww  .  j  a va2  s.c  o  m*/
}

From source file:com.sencha.gxt.cell.core.client.AbstractEventInputCell.java

License:sencha.com license

public void addCellGestureAdapter(CellGestureAdapter<? extends GestureRecognizer, T> cellGestureAdapter) {
    if (cellGestureAdapters == null) {
        cellGestureAdapters = new ArrayList<CellGestureAdapter<? extends GestureRecognizer, T>>();
        if (PointerEventsSupport.impl.isSupported()) {
            consumedEvents.add(PointerEvents.POINTERDOWN.getEventName());
            consumedEvents.add(PointerEvents.POINTERMOVE.getEventName());
            consumedEvents.add(PointerEvents.POINTERUP.getEventName());
            consumedEvents.add(PointerEvents.POINTERCANCEL.getEventName());
        }//w ww  . j  av a 2s  . c  om
        consumedEvents.add(BrowserEvents.TOUCHSTART);
        consumedEvents.add(BrowserEvents.TOUCHMOVE);
        consumedEvents.add(BrowserEvents.TOUCHCANCEL);
        consumedEvents.add(BrowserEvents.TOUCHEND);
    }
    cellGestureAdapter.setDelegate(this);
    cellGestureAdapters.add(cellGestureAdapter);
}

From source file:com.sencha.gxt.cell.core.client.AbstractEventInputCell.java

License:sencha.com license

@Override
public void onBrowserEvent(Context context, Element parent, T value, NativeEvent event,
        ValueUpdater<T> valueUpdater) {
    super.onBrowserEvent(context, parent, value, event, valueUpdater);
    String eventType = event.getType();
    if (BrowserEvents.TOUCHSTART.equals(eventType) || BrowserEvents.TOUCHMOVE.equals(eventType)
            || BrowserEvents.TOUCHCANCEL.equals(eventType) || BrowserEvents.TOUCHEND.equals(eventType)) {
        onTouch(context, parent, value, event, valueUpdater);
    }/*from  ww  w  .  j a  va2  s.c o m*/
}

From source file:com.sencha.gxt.core.client.gestures.AbstractGestureRecognizer.java

License:sencha.com license

@Override
public boolean handle(NativeEvent event) {
    String eventType = event.getType();
    if (eventType.equals(BrowserEvents.TOUCHSTART)
            || eventType.equals(PointerEvents.POINTERDOWN.getEventName())) {
        return handleStart(event);
    } else if (eventType.equals(BrowserEvents.TOUCHMOVE)
            || eventType.equals(PointerEvents.POINTERMOVE.getEventName())) {
        return handleMove(event);
    } else if (eventType.equals(BrowserEvents.TOUCHEND)
            || eventType.equals(PointerEvents.POINTERUP.getEventName())) {
        return handleEnd(event);
    } else if (eventType.equals(BrowserEvents.TOUCHCANCEL)
            || eventType.equals(PointerEvents.POINTERCANCEL.getEventName())) {
        return handleCancel(event);
    } else if (eventType.equals(PointerEvents.POINTERENTER.getEventName())
            || eventType.equals(PointerEvents.POINTERLEAVE.getEventName())
            || eventType.equals(PointerEvents.POINTEROVER.getEventName())) {
        event.preventDefault();/*from   w w  w  . jav  a 2  s. c om*/
        event.stopPropagation();
    } //else, skip, we aren't interested
    return true;
}

From source file:com.sencha.gxt.widget.core.client.grid.CheckBoxSelectionModel.java

License:sencha.com license

/**
 * Creates a CheckBoxSelectionModel with a custom ValueProvider and appearance.
 * //from  www  . j a  va2  s  .c  o m
 * @param valueProvider the ValueProvider to use when constructing a ColumnConfig
 * @param appearance the appearance that should be used to render and update the checkbox
 */
public CheckBoxSelectionModel(ValueProvider<M, M> valueProvider, final CheckBoxColumnAppearance appearance) {
    this.appearance = appearance;
    config = newColumnConfig(valueProvider);
    config.setCellPadding(false);
    config.setWidth(20);
    config.setSortable(false);
    config.setHideable(false);
    config.setResizable(false);
    config.setFixed(true);
    config.setMenuDisabled(true);
    config.setCellClassName(appearance.getCellClassName());
    config.setColumnHeaderClassName(appearance.getCellInnerClassName());

    config.setHeader(appearance.renderHeadCheckBox());
    // allow touch events in
    Set<String> consumedEvents = new HashSet<String>(Arrays.asList(BrowserEvents.TOUCHSTART,
            BrowserEvents.TOUCHMOVE, BrowserEvents.TOUCHCANCEL, BrowserEvents.TOUCHEND));
    if (PointerEventsSupport.impl.isSupported()) {
        consumedEvents.add(PointerEvents.POINTERDOWN.getEventName());
    }
    config.setCell(new AbstractCell<M>(consumedEvents) {
        @Override
        public void onBrowserEvent(Context context, Element parent, M value, NativeEvent event,
                ValueUpdater<M> valueUpdater) {
            super.onBrowserEvent(context, parent, value, event, valueUpdater);

            // If the incoming event is touch, then selection is already taken care of
            // Don't let mouse events to pass through
            String eventType = event.getType();
            if (BrowserEvents.TOUCHSTART.equals(eventType) || BrowserEvents.TOUCHMOVE.equals(eventType)
                    || BrowserEvents.TOUCHCANCEL.equals(eventType) || BrowserEvents.TOUCHEND.equals(eventType)
                    || PointerEventsSupport.impl.isPointerEvent(event)) {
                event.preventDefault();
            }
        }

        @Override
        public void render(Context context, M value, SafeHtmlBuilder sb) {
            CheckBoxSelectionModel.this.render(context, value, sb);
        }
    });

    deselectOnSimpleClick = false;
}

From source file:com.vaadin.client.widget.grid.selection.MultiSelectionRenderer.java

License:Apache License

@Override
public CheckBox createWidget() {
    final CheckBox checkBox = GWT.create(CheckBox.class);
    checkBox.setStylePrimaryName(grid.getStylePrimaryName() + SELECTION_CHECKBOX_CLASSNAME);
    CheckBoxEventHandler handler = new CheckBoxEventHandler(checkBox);

    // Sink events
    checkBox.sinkBitlessEvent(BrowserEvents.MOUSEDOWN);
    checkBox.sinkBitlessEvent(BrowserEvents.TOUCHSTART);
    checkBox.sinkBitlessEvent(BrowserEvents.CLICK);

    // Add handlers
    checkBox.addMouseDownHandler(handler);
    checkBox.addTouchStartHandler(handler);
    checkBox.addClickHandler(handler);/*from  w w w.java2 s .c  o m*/

    return checkBox;
}

From source file:com.vaadin.client.widget.grid.selection.MultiSelectionRenderer.java

License:Apache License

@Override
public Collection<String> getConsumedEvents() {
    final HashSet<String> events = new HashSet<String>();

    /*//from   www.j av  a  2  s  .c o  m
     * this column's first interest is only to attach a NativePreventHandler
     * that does all the magic. These events are the beginning of that
     * cycle.
     */
    events.add(BrowserEvents.MOUSEDOWN);
    events.add(BrowserEvents.TOUCHSTART);

    return events;
}

From source file:com.vaadin.client.widget.grid.selection.MultiSelectionRenderer.java

License:Apache License

@Override
public boolean onBrowserEvent(final CellReference<?> cell, final NativeEvent event) {
    if (BrowserEvents.TOUCHSTART.equals(event.getType()) || (BrowserEvents.MOUSEDOWN.equals(event.getType())
            && event.getButton() == NativeEvent.BUTTON_LEFT)) {
        startDragSelect(event, Element.as(event.getEventTarget()));
        return true;
    } else {//ww  w  .  j  av  a  2s  .co  m
        throw new IllegalStateException("received unexpected event: " + event.getType());
    }
}

From source file:com.vaadin.client.widgets.Grid.java

License:Apache License

private boolean handleHeaderDefaultRowEvent(Event event, RowContainer container) {
    if (container != escalator.getHeader()) {
        return false;
    }/*from  w  ww .  j  a v a 2  s.  c om*/
    if (!getHeader().getRow(eventCell.getRowIndex()).isDefault()) {
        return false;
    }
    if (!eventCell.getColumn().isSortable()) {
        // Only handle sorting events if the column is sortable
        return false;
    }

    if (BrowserEvents.MOUSEDOWN.equals(event.getType()) && event.getShiftKey()) {
        // Don't select text when shift clicking on a header.
        event.preventDefault();
    }

    if (BrowserEvents.TOUCHSTART.equals(event.getType())) {
        if (event.getTouches().length() > 1) {
            return false;
        }

        event.preventDefault();

        Touch touch = event.getChangedTouches().get(0);
        rowEventTouchStartingPoint = new Point(touch.getClientX(), touch.getClientY());

        sorter.sortAfterDelay(GridConstants.LONG_TAP_DELAY, true);

        return true;

    } else if (BrowserEvents.TOUCHMOVE.equals(event.getType())) {
        if (event.getTouches().length() > 1) {
            return false;
        }

        event.preventDefault();

        Touch touch = event.getChangedTouches().get(0);
        double diffX = Math.abs(touch.getClientX() - rowEventTouchStartingPoint.getX());
        double diffY = Math.abs(touch.getClientY() - rowEventTouchStartingPoint.getY());

        // Cancel long tap if finger strays too far from
        // starting point
        if (diffX > GridConstants.LONG_TAP_THRESHOLD || diffY > GridConstants.LONG_TAP_THRESHOLD) {
            sorter.cancelDelayedSort();
        }

        return true;

    } else if (BrowserEvents.TOUCHEND.equals(event.getType())) {
        if (event.getTouches().length() > 1) {
            return false;
        }

        if (sorter.isDelayedSortScheduled()) {
            // Not a long tap yet, perform single sort
            sorter.cancelDelayedSort();
            sorter.sort(eventCell.getColumn(), false);
        }

        return true;

    } else if (BrowserEvents.TOUCHCANCEL.equals(event.getType())) {
        if (event.getTouches().length() > 1) {
            return false;
        }

        sorter.cancelDelayedSort();

        return true;

    } else if (BrowserEvents.CLICK.equals(event.getType())) {

        sorter.sort(eventCell.getColumn(), event.getShiftKey());

        // Click events should go onward to cell focus logic
        return false;
    } else {
        return false;
    }
}