List of usage examples for com.google.gwt.user.client Event getRelatedEventTarget
public final EventTarget getRelatedEventTarget()
From source file:com.alkacon.forms.client.widgets.A_EditWidget.java
License:Open Source License
/** * @see com.google.gwt.user.client.EventListener#onBrowserEvent(com.google.gwt.user.client.Event) *//*from w w w . j av a2 s.c om*/ public void onBrowserEvent(Event event) { switch (DOM.eventGetType(event)) { case Event.ONMOUSEOVER: // Only fire the mouse over event if it's coming from outside this // widget. case Event.ONMOUSEOUT: // Only fire the mouse out event if it's leaving this // widget. Element related = event.getRelatedEventTarget().cast(); if ((related != null) && getElement().isOrHasChild(related)) { return; } break; } DomEvent.fireNativeEvent(event, this, this.getElement()); }
From source file:com.googlecode.kanbanik.client.components.WindowBox.java
License:Apache License
@Override public void onBrowserEvent(Event event) { // If we're not yet dragging, only trigger mouse events if the event occurs // in the caption wrapper if (this.resizable) { switch (event.getTypeInt()) { case Event.ONMOUSEDOWN: case Event.ONMOUSEUP: case Event.ONMOUSEMOVE: case Event.ONMOUSEOVER: case Event.ONMOUSEOUT: if (this.dragMode >= 0 || calcDragMode(event.getClientX(), event.getClientY()) >= 0) { // paste'n'copy from Widget.onBrowserEvent switch (DOM.eventGetType(event)) { case Event.ONMOUSEOVER: // Only fire the mouse over event if it's coming from outside this // widget. case Event.ONMOUSEOUT: // Only fire the mouse out event if it's leaving this // widget. Element related = event.getRelatedEventTarget().cast(); if (related != null && getElement().isOrHasChild(related)) { return; }//from ww w .j a va2s . c om break; } DomEvent.fireNativeEvent(event, this, this.getElement()); return; } if (this.dragMode < 0) this.updateCursor(this.dragMode); } } super.onBrowserEvent(event); }
From source file:com.sencha.gxt.widget.core.client.grid.GridView.java
License:sencha.com license
/** * Handles browser events of interest to the grid view. The default implementation for {@link GridView} includes * support for mouse-over tracking (see {@link GridView#setTrackMouseOver(boolean)} and scroll bar synchronization. * * @param event the browser event//from www . j a v a2s .c om */ protected void handleComponentEvent(Event event) { Element row = Element.is(event.getEventTarget()) ? findRow((Element) event.getEventTarget().cast()) : null; switch (event.getTypeInt()) { case Event.ONMOUSEMOVE: if (overRow != null && row == null) { onRowOut(overRow); } else if (row != null && overRow != row) { if (overRow != null) { onRowOut(overRow); } onRowOver(row); } break; case Event.ONMOUSEOVER: EventTarget from = event.getRelatedEventTarget(); if (from == null || (Element.is(from) && !grid.getElement().isOrHasChild(Element.as(from)))) { Element r = null; if (Element.is(event.getEventTarget())) { r = findRow(Element.as(event.getEventTarget())); } if (r != null) { onRowOver(r); } } break; case Event.ONMOUSEOUT: EventTarget to = event.getRelatedEventTarget(); if (to == null || (Element.is(to) && !grid.getElement().isOrHasChild(Element.as(to)))) { if (overRow != null) { onRowOut(overRow); } } break; case Event.ONMOUSEDOWN: onMouseDown(event); break; case Event.ONSCROLL: if (scroller.isOrHasChild(Element.as(event.getEventTarget()))) { syncScroll(); } break; } if (!trackMouseOver && overRow != null) { trackMouseOver = true; onRowOut(overRow); trackMouseOver = false; } if (event.getTypeInt() == Event.ONSCROLL) { if (scroller.isOrHasChild(Element.as(event.getEventTarget()))) { syncScroll(); } } }
From source file:com.sencha.gxt.widget.core.client.menu.Menu.java
License:sencha.com license
protected void onMouseOut(Event ce) { EventTarget to = ce.getRelatedEventTarget(); if (activeItem != null && (to == null || (Element.is(to) && !activeItem.getElement().isOrHasChild(Element.as(to)))) && activeItem.shouldDeactivate(ce)) { if (to != null && Element.is(to)) { XElement xto = to.cast();// w ww . j av a 2s. c om if (xto.findParent("." + CommonStyles.get().ignore(), 3) != null) { return; } } deactivateActiveItem(); } }
From source file:com.sencha.gxt.widget.core.client.menu.Menu.java
License:sencha.com license
protected void onMouseOver(Event ce) { EventTarget from = ce.getRelatedEventTarget(); if (from == null || (Element.is(from) && !getElement().isOrHasChild(Element.as(from)))) { Widget c = findWidget((Element) ce.getEventTarget().cast()); if (c != null && c instanceof Item) { Item item = (Item) c;/* ww w . j a v a 2 s . c o m*/ if (activeItem != item && item.canActivate && item.isEnabled()) { setActiveItem(item, true); } } } }
From source file:com.sencha.gxt.widget.core.client.tips.QuickTip.java
License:sencha.com license
@Override protected void onTargetOut(Event ce) { EventTarget to = ce.getRelatedEventTarget(); if (to == null || (Element.is(target) && Element.is(to) && !target.isOrHasChild(Element.as(to)))) { super.onTargetOut(ce); }/*from ww w . j av a2s.co m*/ }
From source file:com.smartgwt.mobile.client.widgets.tab.TabSet.java
License:Open Source License
@Override public void onBrowserEvent(Event event) { /*switch(event.getTypeInt()) { case Event.ONMOUSEOVER://w ww. j av a 2s.c o m if (!touched) { if (draggable != null) { final Tab tab = findTarget(event); if (tab != null) { droppable = tab._getTabSetItem(); droppable.fireEvent(new DropOverEvent()); } else if (droppable != null) { droppable.fireEvent(new DropOutEvent()); droppable = null; } } } break; case Event.ONTOUCHMOVE: case Event.ONGESTURECHANGE: if (draggable != null) { final Tab tab = findTarget(event); if (tab != null) { droppable = tab._getTabSetItem(); droppable.fireEvent(new DropOverEvent()); } else if (droppable != null) { droppable.fireEvent(new DropOutEvent()); droppable = null; } } super.onBrowserEvent(event); break; case Event.ONMOUSEUP: if (!touched) { super.onBrowserEvent(event); if (more != null && more.tileLayout != null) { more.tileLayout.onEnd(event); } if (draggable != null && droppable != null) { droppable.fireEvent(new DropEvent(draggable)); droppable = null; } } break; case Event.ONTOUCHEND: case Event.ONGESTUREEND: super.onBrowserEvent(event); if (draggable != null && droppable != null) { droppable.fireEvent(new DropEvent(draggable)); droppable = null; } break; default: super.onBrowserEvent(event); break; }*/ if (Canvas._getHideTabBarDuringKeyboardFocus()) { // On Android devices, SGWT.mobile uses a technique similar to jQuery Mobile's hideDuringFocus // setting to fix the issue that the tabBar unnecessarily takes up a portion of the screen // when the soft keyboard is open. To work around this problem, when certain elements receive // keyboard focus, we add a special class to the TabSet element that hides the tabBar. // This special class is removed on focusout. // // One important consideration is that the user can move between input elements (such as // by using the Next/Previous buttons or by tapping on a different input) and the soft // keyboard will remain on screen. We don't want to show the tabBar only to hide it again. // See: JQM Issue 4724 - Moving through form in Mobile Safari with "Next" and "Previous" // system controls causes fixed position, tap-toggle false Header to reveal itself // https://github.com/jquery/jquery-mobile/issues/4724 final String eventType = event.getType(); if ("focusin".equals(eventType)) { if (EventHandler.couldShowSoftKeyboard(event)) { if (clearHideTabBarDuringFocusTimer != null) { clearHideTabBarDuringFocusTimer.cancel(); clearHideTabBarDuringFocusTimer = null; } getElement().addClassName(_CSS.hideTabBarDuringFocusClass()); } } else if ("focusout".equals(eventType)) { // If the related event target cannot result in the soft keyboard showing, then // there is no need to wait; we can remove the hideTabBarDuringFocus class now. if (event.getRelatedEventTarget() != null && !EventHandler.couldShowSoftKeyboard(event)) { if (clearHideTabBarDuringFocusTimer != null) { clearHideTabBarDuringFocusTimer.cancel(); clearHideTabBarDuringFocusTimer = null; } getElement().removeClassName(_CSS.hideTabBarDuringFocusClass()); // We use a timeout to clear the special CSS class because on Android 4.0.3 (possibly // affects other versions as well), there is an issue where tapping in the 48px above // the soft keyboard (where the tabBar would be) dismisses the soft keyboard. } else { clearHideTabBarDuringFocusTimer = new Timer() { @Override public void run() { clearHideTabBarDuringFocusTimer = null; getElement().removeClassName(_CSS.hideTabBarDuringFocusClass()); } }; clearHideTabBarDuringFocusTimer.schedule(1); } } } }
From source file:com.vaadin.addon.spreadsheet.client.SheetWidget.java
/** * Called when there is a MOUSEOVER or MOUSEOUT on a cell (cell element or * the triangle) that has a cell comment. * * @param event/*from w w w . java 2 s .c om*/ */ private void updateCellCommentDisplay(Event event, Element target) { int eventTypeInt = event.getTypeInt(); String targetClassName = target.getAttribute("class"); if (overlayShouldBeShownFor(targetClassName)) { Element cellElement = target.getParentElement().cast(); String cellElementClassName = cellElement.getAttribute("class"); if (cellElementClassName.endsWith(MERGED_CELL_CLASSNAME)) { cellElementClassName = cellElementClassName.replace(" " + MERGED_CELL_CLASSNAME, ""); } // if comment is always visible, skip it if (alwaysVisibleCellComments.containsKey(cellElementClassName)) { return; } if (eventTypeInt == Event.ONMOUSEOVER) { // MOUSEOVER triangle -> show comment unless already shown if (!(cellCommentOverlay.isVisible() && cellElementClassName.equals(cellCommentCellClassName))) { jsniUtil.parseColRow(cellElementClassName); cellCommentCellColumn = jsniUtil.getParsedCol(); cellCommentCellRow = jsniUtil.getParsedRow(); cellCommentHandler.trigger(); } } else { // MOUSEOUT triangle -> hide comment unless mouse moved on top // of the triangle's cell (parent) Element toElement = event.getRelatedEventTarget().cast(); if (!cellCommentEditMode && !toElement.equals(cellElement)) { cellCommentOverlay.hide(); cellCommentCellClassName = null; cellCommentCellColumn = -1; cellCommentCellRow = -1; } } } else { if (targetClassName.endsWith(MERGED_CELL_CLASSNAME)) { targetClassName = targetClassName.replace(" " + MERGED_CELL_CLASSNAME, ""); } // if comment is always visible, skip it if (alwaysVisibleCellComments.containsKey(targetClassName)) { return; } if (eventTypeInt == Event.ONMOUSEOVER) { // show comment unless already shown if (!(cellCommentOverlay.isVisible() && targetClassName.equals(cellCommentCellClassName))) { Event.setCapture(sheet); jsniUtil.parseColRow(targetClassName); cellCommentCellColumn = jsniUtil.getParsedCol(); cellCommentCellRow = jsniUtil.getParsedRow(); cellCommentHandler.trigger(); } } else if (eventTypeInt == Event.ONMOUSEOUT) { // MOUSEOUT triangle's cell -> hide unless mouse moved back on // top of the same triangle Element toElement = event.getRelatedEventTarget().cast(); if (!cellCommentEditMode && toElement != null && toElement.getParentElement() != null) { try { if (!(overlayShouldBeShownFor(toElement.getAttribute("class")) && toElement.getParentElement().equals(target))) { cellCommentOverlay.hide(); cellCommentCellClassName = null; cellCommentCellRow = -1; cellCommentCellColumn = -1; } } catch (NullPointerException npe) { debugConsole.warning( "SheetWidget:updateCellCommentDisplay: NPE ONMOUSEOUT, " + npe.getMessage()); } } } } }
From source file:com.wallissoftware.pushstate.client.ui.HyperlinkPushState.java
License:Apache License
public void onBrowserEvent(Event event) { switch (DOM.eventGetType(event)) { case Event.ONMOUSEOVER: // Only fire the mouse over event if it's coming from outside this // widget. case Event.ONMOUSEOUT: // Only fire the mouse out event if it's leaving this // widget. Element related = event.getRelatedEventTarget().cast(); if (related != null && getElement().isOrHasChild(related)) { return; }//from w w w. j a va 2 s . c o m break; } DomEvent.fireNativeEvent(event, this, this.getElement()); if (DOM.eventGetType(event) == Event.ONCLICK) { HISTORIAN.newItem(getTargetHistoryToken(), true); event.preventDefault(); } }
From source file:org.waveprotocol.wave.client.editor.sugg.SuggestionMenu.java
License:Apache License
private void handleEventInner(Event event) { switch (DOM.eventGetType(event)) { case Event.ONCONTEXTMENU: event.preventDefault();//from w ww . ja v a 2 s .com break; case Event.ONKEYPRESS: case Event.ONKEYDOWN: { // NOTE(user): It is necessary to stop propagation on the key events to // prevent them from leaking to the blip/wave presenters. int keyCode = DOM.eventGetKeyCode(event); // Move left/right to previous/next drop down widget switch (keyCode) { case KeyCodes.KEY_LEFT: case KeyCodes.KEY_RIGHT: handler.handleLeftRight(keyCode == KeyCodes.KEY_RIGHT); event.stopPropagation(); return; case KeyCodes.KEY_ENTER: event.stopPropagation(); } if (keyCode >= '1' && keyCode <= '9') { // TODO(danilatos): Is this ok? i18n etc? int index = keyCode - '1'; if (index >= 0 && index < getItems().size()) { MenuItem item = getItems().get(index); if (item == null) { return; } item.getCommand().execute(); DOM.eventPreventDefault(event); } } break; } case Event.ONMOUSEOUT: { // Need to check that we really seem to have left the menu, as // mouse-out events get triggered whenever the mouse moves between // selections in the menu. EventTarget target = event.getRelatedEventTarget(); Element targetElement = Element.as(target); if (!getElement().isOrHasChild(targetElement)) { handler.handleMouseOut(); } break; } case Event.ONMOUSEOVER: { handler.handleMouseOver(); break; } } }