Example usage for com.google.gwt.event.dom.client TouchEvent isSupported

List of usage examples for com.google.gwt.event.dom.client TouchEvent isSupported

Introduction

In this page you can find the example usage for com.google.gwt.event.dom.client TouchEvent isSupported.

Prototype

public static boolean isSupported() 

Source Link

Document

Runtime check for whether touch scrolling is supported in this browser.

Usage

From source file:com.vaadin.addon.spreadsheet.client.SpreadsheetWidget.java

public SpreadsheetWidget() {

    setTouchMode(TouchEvent.isSupported());

    sheetWidget = new SheetWidget(this, touchMode);
    formulaBarWidget = new FormulaBarWidget(this, sheetWidget);
    sheetTabSheet = new SheetTabSheet(this);
    selectionHandler = new SelectionHandler(this, sheetWidget);

    sheetWidget.getElement().appendChild(formulaBarWidget.getElement());
    sheetWidget.getElement().appendChild(sheetTabSheet.getElement());

    initWidget(sheetWidget);//from www.j  a  v a 2  s. c o m

    //There is a bug in CssLayout/VerticalLayout.
    //If a component calls setVisible(false) another component in the layout
    //next to it is detached and then attached to the layout and the scroll
    //position is reset. We need to store the scroll position on detach and
    //then set on attach event.
    sheetWidget.addAttachHandler(new AttachEvent.Handler() {
        int leftScrollPosition = 0;
        int topScrollPosition = 0;

        @Override
        public void onAttachOrDetach(AttachEvent attachEvent) {
            if (attachEvent.isAttached()) {
                sheetWidget.setScrollPosition(leftScrollPosition, topScrollPosition);
            } else {
                leftScrollPosition = sheetWidget.getSheetScrollLeft();
                topScrollPosition = sheetWidget.getSheetScrollTop();
            }

        }
    });
}