Java Code Examples for com.google.gwt.user.client.Event#NativePreviewEvent
The following examples show how to use
com.google.gwt.user.client.Event#NativePreviewEvent .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CubaPopupButtonConnector.java From cuba with Apache License 2.0 | 6 votes |
protected void handleMouseOver(@SuppressWarnings("unused") Event.NativePreviewEvent event, Element target) { if (!getState().customLayout && getWidget().popupHasChild(target)) { Widget widget = WidgetUtil.findWidget(target, null); if ((widget instanceof VButton || widget instanceof VUpload || widget instanceof CubaFileUploadWidget)) { VButton button; if (widget instanceof VButton) { button = (VButton) widget; } else if (widget instanceof CubaFileUploadWidget) { button = ((CubaFileUploadWidget) widget).getSubmitButton(); } else { button = ((VUpload) widget).submitButton; } if (!button.getStyleName().contains(SELECTED_ITEM_STYLE)) { getWidget().childWidgetFocused(button); button.setFocus(true); } } } }
Example 2
Source File: CubaFileUploadProgressWindow.java From cuba with Apache License 2.0 | 5 votes |
@Override protected void onPreviewNativeEvent(Event.NativePreviewEvent event) { if (dragging) { Event e = Event.as(event.getNativeEvent()); onDragEvent(e); event.cancel(); } }
Example 3
Source File: CubaPopupButtonConnector.java From cuba with Apache License 2.0 | 5 votes |
protected void handleClick(@SuppressWarnings("unused") Event.NativePreviewEvent event, Element target) { if (getState().autoClose && getWidget().popupHasChild(target)) { Scheduler.get().scheduleDeferred(() -> { getWidget().hidePopup(); // update state on server rpc.setPopupVisible(false); }); } }
Example 4
Source File: Tools.java From cuba with Apache License 2.0 | 5 votes |
@Override protected void onPreviewNativeEvent(Event.NativePreviewEvent event) { super.onPreviewNativeEvent(event); NativeEvent nativeEvent = event.getNativeEvent(); Element target = Element.as(nativeEvent.getEventTarget()); if (Event.ONCLICK == event.getTypeInt()) { if (getElement().isOrHasChild(target)) { Scheduler.get().scheduleDeferred(this::hide); } } previewTableContextMenuEvent(event); }
Example 5
Source File: ListPopupPanel2.java From consulo with Apache License 2.0 | 5 votes |
/** See class docs */ @Override public void onPreviewNativeEvent(Event.NativePreviewEvent nativePreviewEvent) { if (nativePreviewEvent.getTypeInt() != Event.ONCLICK) { return; } Element source = (Element) Element.as(nativePreviewEvent.getNativeEvent().getEventTarget()); if (!DOM.isOrHasChild(getElement(), source) && !DOM.isOrHasChild(getComboBox().getElement(), source)) { hide(); getComboBox().getChoiceButton().setDown(false); } }
Example 6
Source File: GuidedTourHelper.java From core with GNU Lesser General Public License v2.1 | 5 votes |
static void init(BootstrapContext bootstrapContext) { String locale = Preferences.get(Preferences.Key.LOCALE, "en"); String url = bootstrapContext.getProperty(ApplicationProperties.GUIDED_TOUR) + "/" + (bootstrapContext.isStandalone() ? "standalone" : "domain") + "/step1.html?setLng=" + locale; Frame tourFrame = new Frame(url); tourFrame.setWidth("100%"); tourFrame.setHeight("100%"); guidedTour = new PopupPanel(true, true) { { Window.addResizeHandler(resizeEvent -> { if (isShowing()) { center(); } }); } @Override protected void onPreviewNativeEvent(Event.NativePreviewEvent event) { if (Event.ONKEYUP == event.getTypeInt()) { if (event.getNativeEvent().getKeyCode() == KeyboardEvent.KeyCode.ESC) { hide(); } } } }; guidedTour.setGlassEnabled(true); guidedTour.setAnimationEnabled(false); guidedTour.setWidget(tourFrame); guidedTour.setWidth("1120px"); guidedTour.setHeight("800px"); guidedTour.setStyleName("default-window"); exportCloseMethod(); }
Example 7
Source File: DefaultPopup.java From core with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected void onPreviewNativeEvent(Event.NativePreviewEvent event) { if (Event.ONKEYDOWN == event.getTypeInt()) { if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ESCAPE) { // Dismiss when escape is pressed hide(); } } }
Example 8
Source File: OffPageSelector.java From core with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected void onPreviewNativeEvent(Event.NativePreviewEvent event) { if (Event.ONKEYDOWN == event.getTypeInt()) { if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ESCAPE) { // Dismiss when escape is pressed hide(); } } }
Example 9
Source File: MessageCenterView.java From core with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected void onPreviewNativeEvent(Event.NativePreviewEvent event) { if (Event.ONKEYDOWN == event.getTypeInt()) { if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ESCAPE) { // Dismiss when escape is pressed hide(); } } }
Example 10
Source File: MessageCenterView.java From core with GNU Lesser General Public License v2.1 | 5 votes |
private PopupPanel createDisplay(Message message) { PopupPanel displayPopup = new PopupPanel() { { this.sinkEvents(Event.ONKEYDOWN); getElement().setAttribute("role", "alert"); getElement().setAttribute("aria-live", "assertive"); if(!message.isSticky()) { setAutoHideEnabled(true); setAutoHideOnHistoryEventsEnabled(true); } } @Override protected void onPreviewNativeEvent(Event.NativePreviewEvent event) { if (Event.ONKEYDOWN == event.getTypeInt()) { if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ESCAPE) { // Dismiss when escape is pressed hide(); } } } }; displayPopup.addStyleName("back"); return displayPopup; }
Example 11
Source File: WidgetComboBox.java From consulo with Apache License 2.0 | 4 votes |
/** * See class docs */ @Override public void onPreviewNativeEvent(Event.NativePreviewEvent event) { NativeEvent nativeEvent = event.getNativeEvent(); EventTarget eventTarget = nativeEvent.getEventTarget(); if (!Element.is(eventTarget)) //chrome fix { return; } Element target = (Element)Element.as(eventTarget); int type = event.getTypeInt(); if (type == Event.ONKEYDOWN) { setKeyPressed(true); if (DOM.getCaptureElement() != null) return; boolean eventTargetsPopup = (target != null) && DOM.isOrHasChild(getElement(), target); int button = nativeEvent.getKeyCode(); boolean alt = nativeEvent.getAltKey(); boolean ctrl = nativeEvent.getCtrlKey(); boolean shift = nativeEvent.getShiftKey(); boolean hasModifiers = alt || ctrl || shift; if (eventTargetsPopup && isListPanelOpened()) { if (button == KeyCodes.KEY_UP && !hasModifiers) { moveCursor(-1); cancelAndPrevent(event); } else if (button == KeyCodes.KEY_DOWN && !hasModifiers) { moveCursor(1); cancelAndPrevent(event); } else if (button == KeyCodes.KEY_ENTER && !hasModifiers) { select(getHighlightRow()); getChoiceButton().setFocus(false); ChangeEvent changeEvent = new ComboBoxChangeEvent(getHighlightRow(), ComboBoxChangeEvent.ChangeEventInputDevice.KEYBOARD); fireEvent(changeEvent); setKeyPressed(false); } else if (button == KeyCodes.KEY_ESCAPE && !hasModifiers) { hideList(); setKeyPressed(false); } else if (button == KeyCodes.KEY_TAB && (!hasModifiers || !alt && !ctrl && shift)) { hideList(); setKeyPressed(false); } } else if (eventTargetsPopup && !hasModifiers && button == KeyCodes.KEY_ENTER && getModel().getCount() > 0) { showList(true); } } else if (type == Event.ONKEYUP) { setKeyPressed(false); } }
Example 12
Source File: ComboPicker.java From core with GNU Lesser General Public License v2.1 | 4 votes |
public ComboPicker(String cssSuffix) { cellList = new CellList<String>(new TextCell() { @Override public void render(Context context, String data, SafeHtmlBuilder sb) { String cssName = (context.getIndex() %2 > 0) ? "combobox-item combobox-item-odd" : "combobox-item"; if(data.equals(displayed.getActual())) cssName+=" combobox-item-selected"; sb.append(TEMPLATE.item(cssName, data)); } }); cellList.setPageSize(100); final SingleSelectionModel<String> selectionModel = new SingleSelectionModel<String>(); cellList.setSelectionModel(selectionModel); selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { public void onSelectionChange(SelectionChangeEvent event) { String selectedValue = selectionModel.getSelectedObject(); setDisplayedValue(selectedValue); popup.hide(); onSelection(selectedValue); } }); final String panelId = "combopicker_popup"; popup = new PopupPanel(true, true) { @Override protected void onPreviewNativeEvent(Event.NativePreviewEvent event) { if (Event.ONKEYUP == event.getTypeInt()) { if (event.getNativeEvent().getKeyCode() == ESCAPE) { // Dismiss when escape is pressed popup.hide(); } } } public void onBrowserEvent(Event event) { super.onBrowserEvent(event); } }; popup.getElement().setId(panelId); popup.setStyleName("default-popup"); popup.addStyleName("triangle-border"); popup.addStyleName("top-left"); popup.setWidget(new ScrollPanel(cellList)); displayed = new Display(""); header = new HorizontalPanel(); header.setStyleName("combobox"+cssSuffix); header.add(displayed); HTML icon = new HTML("<span style='font-size:12px;cursor:pointer'><i class='icon-chevron-down'></i></span>"); header.add(icon); displayed.getElement().getParentElement().setAttribute("width", "100%"); icon.getParent().getElement().setAttribute("width", "18"); //header.getElement().setAttribute("width", "95%"); header.getElement().setAttribute("cellspacing", "0"); header.getElement().setAttribute("cellpadding", "0"); header.getElement().setAttribute("border", "0"); ClickHandler clickHandler = new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { openPanel(); } }; displayed.addClickHandler(clickHandler); icon.addClickHandler(clickHandler); }
Example 13
Source File: WidgetComboBox.java From consulo with Apache License 2.0 | 2 votes |
/** * This method cancels and prevents default actions of the specified event.<p/> * It's useful for stupid browsers like Opera. * * @param event is an event to cancel and prevent. */ protected void cancelAndPrevent(Event.NativePreviewEvent event) { event.getNativeEvent().preventDefault(); event.cancel(); }