List of usage examples for com.google.gwt.user.client.ui Focusable setFocus
void setFocus(boolean focused);
From source file:co.fxl.gui.gwt.GWTElement.java
License:Open Source License
@SuppressWarnings("unchecked") protected R focus(final boolean focus, Widget widget) { if (widget.isVisible() && widget.isAttached()) { Focusable focusable = (Focusable) widget; focusable.setFocus(focus); notifyFocusListeners(focus);/*w w w.ja v a 2 s . co m*/ } return (R) this; }
From source file:com.vaadin.client.WidgetUtil.java
License:Apache License
public static void simulateClickFromTouchEvent(Event touchevent, Widget widget) { Touch touch = touchevent.getChangedTouches().get(0); final NativeEvent createMouseUpEvent = Document.get().createMouseUpEvent(0, touch.getScreenX(), touch.getScreenY(), touch.getClientX(), touch.getClientY(), false, false, false, false, NativeEvent.BUTTON_LEFT);/* ww w . j a v a 2s . co m*/ final NativeEvent createMouseDownEvent = Document.get().createMouseDownEvent(0, touch.getScreenX(), touch.getScreenY(), touch.getClientX(), touch.getClientY(), false, false, false, false, NativeEvent.BUTTON_LEFT); final NativeEvent createMouseClickEvent = Document.get().createClickEvent(0, touch.getScreenX(), touch.getScreenY(), touch.getClientX(), touch.getClientY(), false, false, false, false); /* * Get target with element from point as we want the actual element, not * the one that sunk the event. */ final Element target = getElementFromPoint(touch.getClientX(), touch.getClientY()); /* * Fixes infocusable form fields in Safari of iOS 5.x and some Android * browsers. */ Widget targetWidget = findWidget(target, null); if (targetWidget instanceof com.google.gwt.user.client.ui.Focusable) { final com.google.gwt.user.client.ui.Focusable toBeFocusedWidget = (com.google.gwt.user.client.ui.Focusable) targetWidget; toBeFocusedWidget.setFocus(true); } else if (targetWidget instanceof Focusable) { ((Focusable) targetWidget).focus(); } Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { try { target.dispatchEvent(createMouseDownEvent); target.dispatchEvent(createMouseUpEvent); target.dispatchEvent(createMouseClickEvent); } catch (Exception e) { } } }); }
From source file:cz.filmtit.client.subgestbox.PosteditHandler.java
License:Open Source License
@Override public void onKeyDown(KeyDownEvent event) { if (event.getSource() instanceof PosteditBox) { if (isThisKeyEvent(event, KeyCodes.KEY_DOWN)) { event.preventDefault(); // default is to scroll down the page or to move to the next line in the textarea PosteditBox posteditBox = (PosteditBox) event.getSource(); Focusable suggestionsList = ((Focusable) ((SimplePanel) posteditBox.getPosteditWidget()) .getWidget());/*www . j a v a 2s.com*/ Gui.log("setting focus to postedit suggestions"); suggestionsList.setFocus(true); } // pressing Esc: else if (isThisKeyEvent(event, KeyCodes.KEY_ESCAPE)) { // hide the suggestion widget corresponding to the SubgestBox // which previously had focus (PopupPanel does not hide on keyboard events) workspace.deactivateSuggestionWidget(); workspace.deactivatePosteditWidget(); } // pressing Tab: else if (isThisKeyEvent(event, KeyCodes.KEY_TAB)) { event.preventDefault(); // e.g. in Chrome, default is to insert TAB character in the textarea workspace.deactivateSuggestionWidget(); workspace.deactivatePosteditWidget(); PosteditBox posteditBox = (PosteditBox) event.getSource(); if (event.isShiftKeyDown()) { workspace.goToPreviousBox(posteditBox); } else { workspace.goToNextBox(posteditBox); } } } }
From source file:cz.filmtit.client.subgestbox.SubgestHandler.java
License:Open Source License
@Override public void onKeyDown(KeyDownEvent event) { if (event.getSource() instanceof SubgestBox) { // pressing the Down arrow - setting focus to the suggestions: if (isThisKeyEvent(event, KeyCodes.KEY_DOWN)) { event.preventDefault(); // default is to scroll down the page or to move to the next line in the textarea SubgestBox subbox = (SubgestBox) event.getSource(); Focusable suggestionsList = ((Focusable) ((SimplePanel) subbox.getSuggestionWidget()).getWidget()); Gui.log("setting focus to suggestions"); suggestionsList.setFocus(true); } // pressing Esc: else if (isThisKeyEvent(event, KeyCodes.KEY_ESCAPE)) { // hide the suggestion widget corresponding to the SubgestBox // which previously had focus (PopupPanel does not hide on keyboard events) workspace.deactivateSuggestionWidget(); workspace.deactivatePosteditWidget(); } // pressing Tab: else if (isThisKeyEvent(event, KeyCodes.KEY_TAB)) { event.preventDefault(); // e.g. in Chrome, default is to insert TAB character in the textarea workspace.deactivateSuggestionWidget(); workspace.deactivatePosteditWidget(); SubgestBox subbox = (SubgestBox) event.getSource(); if (event.isShiftKeyDown()) { workspace.goToPreviousBox(subbox); } else { workspace.goToNextBox(subbox); }//w ww. j a va2s . c o m } } }
From source file:fr.putnami.pwt.core.widget.client.FormGroup.java
License:Open Source License
@Override public void setFocus(boolean focused) { if (editor instanceof Focusable) { Focusable focusable = (Focusable) editor; focusable.setFocus(focused); }/*from ww w . j a va 2s.co m*/ }
From source file:ilarkesto.gwt.client.desktop.Widgets.java
License:Open Source License
/** * Focus the first focusable widget in the given widget or its child widgets. * * @param widget//w w w . j av a 2s.com * @return the widget which was focused */ public static Focusable focus(IsWidget widget) { if (widget == null) return null; if (widget instanceof DateBox) { DateBox dateBox = (DateBox) widget; Focusable focusable = dateBox.getTextBox(); focusable.setFocus(true); return focusable; } else if (widget instanceof Focusable) { Focusable focusable = (Focusable) widget; focusable.setFocus(true); return focusable; } if (widget instanceof HasOneWidget) return focus(((HasOneWidget) widget).getWidget()); if (widget instanceof HasWidgets) { Iterator<Widget> iterator = ((HasWidgets) widget).iterator(); while (iterator.hasNext()) { Focusable focusable = focus(iterator.next()); if (focusable != null) return focusable; } } return null; }
From source file:net.sf.mmm.client.ui.impl.gwt.widget.adapter.UiWidgetAdapterGwtWidgetActive.java
License:Apache License
/** * {@inheritDoc}/*from w w w . jav a2 s. c om*/ */ @Override public final boolean setFocused() { Focusable focusWidget = getWidgetAsFocusable(); if (focusWidget != null) { EventAdapterGwt eventAdapter = getEventAdapter(); if (eventAdapter != null) { eventAdapter.setProgrammaticEventType(EventType.FOCUS_GAIN); } focusWidget.setFocus(true); return true; } return false; }
From source file:org.apache.hupa.client.validation.SetFocusAction.java
License:Apache License
@Override public void invoke(ValidationResult result, Focusable widget) { InstrumentationLoggerProvider.get()/*from w w w . java 2s. co m*/ .instrument("org_apache_hupa_client_validation_SetFocusAction_java0x0ef5332a250fd1225"); InstrumentationLoggerProvider.get().instrument( "org_apache_hupa_client_validation_SetFocusAction_java0x0ef5332a250fd12250x30x0_____org_apache_hupa_client_validation_SetFocusAction_java0x0ef5332a250fd12250x20x0_____org_apache_hupa_client_validation_SetFocusAction_java0x0ef5332a250fd12250x3_____org_apache_hupa_client_validation_SetFocusAction_java0x0ef5332a250fd12250x4_____org_apache_hupa_client_validation_SetFocusAction_java0x0ef5332a250fd12250x2_____org_apache_hupa_client_validation_SetFocusAction_java0x0ef5332a250fd12250x0_____org_apache_hupa_client_validation_SetFocusAction_java0x0ef5332a250fd12250x1"); InstrumentationLoggerProvider.get().instrument( "org_apache_hupa_client_validation_SetFocusAction_java0x0ef5332a250fd12250x40x00x0_____org_apache_hupa_client_validation_SetFocusAction_java0x0ef5332a250fd12250x40x0"); widget.setFocus(true); }
From source file:org.cruxframework.crux.widgets.client.grid.Grid.java
License:Apache License
/** * Sets the focus to the editor at the clicked cell or to the first * focusable one at the row.// www .ja v a 2 s.c o m * * @param editors * @param editableColumns * @param focusCellKey */ private void chooseFocusedEditor(FastList<Widget> editors, FastList<String> editableColumns, String focusCellKey) { if (editors != null && editors.size() > 0) { for (int i = 0; i < editors.size(); i++) { Widget editorWidget = editors.get(i); String key = editableColumns.get(i); if (editorWidget instanceof Focusable) { if (focusCellKey == null || focusCellKey.equals(key)) { final Focusable focusable = (Focusable) editorWidget; Scheduler.get().scheduleDeferred(new ScheduledCommand() { public void execute() { focusable.setFocus(true); } }); break; } } } } }
From source file:org.eclipse.che.ide.ui.window.Window.java
License:Open Source License
/** * Displays the {@link Window} popup. The popup will animate into view. * * @param selectAndFocusElement// w w w . j a v a 2 s .c o m * an {@link Focusable} to select and focus on when the panel is * shown. If null, no element will be given focus */ public void show(@Nullable final Focusable selectAndFocusElement) { setBlocked(false); if (isShowing) { return; } isShowing = true; // Attach the popup to the body. final JsElement popup = view.popup.getElement().cast(); if (popup.getParentElement() == null) { // Hide the popup so it can enter its initial state without flickering. popup.getStyle().setVisibility("hidden"); RootLayoutPanel.get().add(view); } // The popup may have been hidden before this timer executes. if (isShowing) { popup.getStyle().removeProperty("visibility"); // Start the animation after the element is attached. Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { // The popup may have been hidden before this timer executes. view.setShowing(true); if (selectAndFocusElement != null) { selectAndFocusElement.setFocus(true); } } }); } }