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

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

Introduction

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

Prototype

String FOCUS

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

Click Source Link

Usage

From source file:com.bearsoft.gwt.ui.widgets.grid.cells.RenderedEditorCell.java

public RenderedEditorCell(Widget aEditor) {
    super(aEditor, BrowserEvents.DBLCLICK, BrowserEvents.KEYDOWN, BrowserEvents.FOCUS, BrowserEvents.BLUR);
}

From source file:com.gwtmodel.table.view.table.edit.PresentationEditCellHelper.java

License:Apache License

protected void afterChange(String eventType, Context context, IVField v, WSize w) {
    if (eventType.equals(BrowserEvents.CHANGE)) {
        modifUpdate(false, context.getKey(), v, w);
    }/*from  www . j a v a 2 s . com*/
    if (eventType.equals(BrowserEvents.FOCUS)) {
        modifUpdate(true, context.getKey(), v, w);
    }
}

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

License:Apache License

@Override
public void onBrowserEvent(Event event) {
    if (!isEnabled()) {
        return;//  www. java  2  s . com
    }

    String eventType = event.getType();

    if (eventType.equals(BrowserEvents.FOCUS) || eventType.equals(BrowserEvents.BLUR)) {
        super.onBrowserEvent(event);
        return;
    }

    EventTarget target = event.getEventTarget();

    if (!Element.is(target) || isOrContainsInSpacer(Element.as(target))) {
        return;
    }

    Element e = Element.as(target);
    RowContainer container = escalator.findRowContainer(e);
    Cell cell;

    if (container == null) {
        if (eventType.equals(BrowserEvents.KEYDOWN) || eventType.equals(BrowserEvents.KEYUP)
                || eventType.equals(BrowserEvents.KEYPRESS)) {
            cell = cellFocusHandler.getFocusedCell();
            container = cellFocusHandler.containerWithFocus;
        } else {
            // Click might be in an editor cell, should still map.
            if (editor.editorOverlay != null && editor.editorOverlay.isOrHasChild(e)) {
                container = escalator.getBody();
                int rowIndex = editor.getRow();
                int colIndex = editor.getElementColumn(e);

                if (colIndex < 0) {
                    // Click in editor, but not for any column.
                    return;
                }

                TableCellElement cellElement = container.getRowElement(rowIndex).getCells().getItem(colIndex);

                cell = new Cell(rowIndex, colIndex, cellElement);
            } else {
                if (escalator.getElement().isOrHasChild(e)) {
                    eventCell.set(new Cell(-1, -1, null), Section.BODY);
                    // Fire native events.
                    super.onBrowserEvent(event);
                }
                return;
            }
        }
    } else {
        cell = container.getCell(e);
        if (eventType.equals(BrowserEvents.MOUSEDOWN)) {
            cellOnPrevMouseDown = cell;
        } else if (cell == null && eventType.equals(BrowserEvents.CLICK)) {
            /*
             * Chrome has an interesting idea on click targets (see
             * cellOnPrevMouseDown javadoc). Firefox, on the other hand, has
             * the mousedown target as the click target.
             */
            cell = cellOnPrevMouseDown;
        }
    }

    assert cell != null : "received " + eventType + "-event with a null cell target";
    eventCell.set(cell, getSectionFromContainer(container));

    // Editor can steal focus from Grid and is still handled
    if (isEditorEnabled() && handleEditorEvent(event, container)) {
        return;
    }

    // Fire GridKeyEvents and GridClickEvents. Pass the event to escalator.
    super.onBrowserEvent(event);

    if (!isElementInChildWidget(e)) {

        if (handleHeaderCellDragStartEvent(event, container)) {
            return;
        }

        // Sorting through header Click / KeyUp
        if (handleHeaderDefaultRowEvent(event, container)) {
            return;
        }

        if (handleRendererEvent(event, container)) {
            return;
        }

        if (handleCellFocusEvent(event, container)) {
            return;
        }
    }
}

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

License:Apache License

@Override
public void onBrowserEvent(Event event) {
    if (!isEnabled()) {
        return;/*from  w w  w. ja v  a2s. c  o  m*/
    }

    String eventType = event.getType();

    if (eventType.equals(BrowserEvents.FOCUS) || eventType.equals(BrowserEvents.BLUR)) {
        super.onBrowserEvent(event);
        return;
    }

    EventTarget target = event.getEventTarget();

    if (!Element.is(target) || isOrContainsInSpacer(Element.as(target))) {
        return;
    }

    Element e = Element.as(target);
    RowContainer container = escalator.findRowContainer(e);
    Cell cell;

    if (container == null) {
        if (eventType.equals(BrowserEvents.KEYDOWN) || eventType.equals(BrowserEvents.KEYUP)
                || eventType.equals(BrowserEvents.KEYPRESS)) {
            cell = cellFocusHandler.getFocusedCell();
            container = cellFocusHandler.containerWithFocus;
        } else {
            // Click might be in an editor cell, should still map.
            if (editor.editorOverlay != null && editor.editorOverlay.isOrHasChild(e)) {
                container = escalator.getBody();
                int rowIndex = editor.getRow();
                int colIndex = editor.getElementColumn(e);

                if (colIndex < 0) {
                    // Click in editor, but not for any column.
                    return;
                }

                TableCellElement cellElement = container.getRowElement(rowIndex).getCells().getItem(colIndex);

                cell = new Cell(rowIndex, colIndex, cellElement);
            } else {
                if (escalator.getElement().isOrHasChild(e)) {
                    eventCell.set(new Cell(-1, -1, null), Section.BODY);
                    // Fire native events.
                    super.onBrowserEvent(event);
                }
                return;
            }
        }
    } else {
        cell = container.getCell(e);
        if (eventType.equals(BrowserEvents.MOUSEDOWN)) {
            cellOnPrevMouseDown = cell;
        } else if (cell == null && eventType.equals(BrowserEvents.CLICK)) {
            /*
             * Chrome has an interesting idea on click targets (see
             * cellOnPrevMouseDown javadoc). Firefox, on the other hand, has
             * the mousedown target as the click target.
             */
            cell = cellOnPrevMouseDown;
        }
    }

    assert cell != null : "received " + eventType + "-event with a null cell target";
    eventCell.set(cell, getSectionFromContainer(container));

    GridEvent<T> gridEvent = new GridEvent<>(event, eventCell);
    for (GridEventHandler<T> handler : browserEventHandlers) {
        handler.onEvent(gridEvent);
    }
}

From source file:gwt.material.design.client.ui.table.AbstractDataTable.java

License:Apache License

@Override
public void onBrowserEvent(Event event) {
    CellBasedWidgetImpl.get().onBrowserEvent(this, event);

    // Ignore spurious events (such as onblur) while we refresh the table.
    if (refreshing) {
        return;//ww w  . j  a v  a  2 s. co m
    }

    // Verify that the target is still a child of this widget. IE fires focus
    // events even after the element has been removed from the DOM.
    EventTarget eventTarget = event.getEventTarget();
    if (!Element.is(eventTarget)) {
        return;
    }
    Element target = Element.as(eventTarget);
    if (!getElement().isOrHasChild(Element.as(eventTarget))) {
        return;
    }
    super.onBrowserEvent(event);

    String eventType = event.getType();
    if (BrowserEvents.FOCUS.equals(eventType)) {
        // Remember the focus state.
        focused = true;
        onFocus();
    } else if (BrowserEvents.BLUR.equals(eventType)) {
        // Remember the blur state.
        focused = false;
        onBlur();
    } else if (BrowserEvents.KEYDOWN.equals(eventType)) {
        // A key event indicates that we already have focus.
        focused = true;
    } else if (BrowserEvents.MOUSEDOWN.equals(eventType)
            && CellBasedWidgetImpl.get().isFocusable(Element.as(target))) {
        // If a natively focusable element was just clicked, then we must have
        // focus.
        focused = true;
    }
}