List of usage examples for com.vaadin.client WidgetUtil focus
public static native void focus(Element el) ;
From source file:com.haulmont.cuba.web.toolkit.ui.client.renderers.componentrenderer.componentcellkey.EnterKeyDownHandler.java
License:Apache License
@Override public void onKeyDown(GridKeyDownEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { if (isCellContainingComponent(event.getFocusedCell())) { // if the ENTER key-event's propagation is not stopped it would // be propagated to the newly focused component, which e.g. in the // case of a button leads to an immediate button press event.preventDefault();/*from w ww . j a v a 2 s . co m*/ event.stopPropagation(); Element componentElement = extractComponentElement(event.getFocusedCell()); WidgetUtil.focus(componentElement); focusInputField(componentElement); } } }
From source file:com.haulmont.cuba.web.toolkit.ui.client.renderers.componentrenderer.componentcellkey.EnterKeyDownHandler.java
License:Apache License
private void focusInputField(Element componentElement) { for (int i = 0; i < componentElement.getChildNodes().getLength(); i++) { Node node = componentElement.getChildNodes().getItem(i); if (node.getNodeName().equals("INPUT") || node.getNodeName().equals("SELECT")) { WidgetUtil.focus((Element) node); break; }/*from w w w .j av a 2 s . com*/ } }
From source file:com.haulmont.cuba.web.toolkit.ui.client.renderers.componentrenderer.componentcellkey.EscKeyDownHandler.java
License:Apache License
@Override public void onKeyDown(KeyDownEvent keyDownEvent) { if (keyDownEvent.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) { SimplePanel panel = WidgetUtil.findWidget(WidgetUtil.getFocusedElement(), SimplePanel.class); if (panel != null) { WidgetUtil.focus(panel.getParent().getElement()); // prevent further bubbling of the event as it has only // navigational purpose if thrown at this depth. A subsequent // press of ESC is not stopped, so ESC abort actions of the // application should work as soon as the focus is in // "navigational mode" on a grid-cell keyDownEvent.preventDefault(); keyDownEvent.stopPropagation(); }// ww w . ja v a2 s . co m } }
From source file:com.haulmont.cuba.web.toolkit.ui.client.renderers.componentrenderer.focuspreserve.FocusPreservingRefreshClientRpcImpl.java
License:Apache License
@Override public void restoreFocus() { WidgetUtil.focus(focus); }