Search in sources :

Example 6 with EventTarget

use of com.google.gwt.dom.client.EventTarget in project drools-wb by kiegroup.

the class RadarMenuViewImpl method setup.

@PostConstruct
public void setup() {
    radarCanvas.add(radarLayer);
    radarMenuDropdown.setTitle(translationService.getTranslation(GuidedDecisionTableErraiConstants.RowContextMenuViewImpl_Title));
    visibleBounds.setDraggable(true);
    visibleBounds.addNodeDragMoveHandler(new NodeDragMoveHandler() {

        @Override
        public void onNodeDragMove(final NodeDragMoveEvent event) {
            presenter.onDragVisibleBounds(visibleBounds.getX(), visibleBounds.getY());
        }
    });
    visibleBounds.setFillColor(ColorName.GRAY);
    visibleBounds.setAlpha(0.25);
    visibleBounds.setLocation(new Point2D((RADAR_WIDTH - visibleBounds.getWidth()) / 2, (RADAR_HEIGHT - visibleBounds.getHeight()) / 2));
    radarLayer.add(visibleBounds);
    radarCanvas.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            if (eventTargetsPopup(event.getNativeEvent(), radarMenu)) {
                event.stopPropagation();
                event.preventDefault();
            }
        }

        private boolean eventTargetsPopup(final NativeEvent event, final Element element) {
            final EventTarget target = event.getEventTarget();
            if (Element.is(target)) {
                return element.isOrHasChild(Element.as(target));
            }
            return false;
        }
    });
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) Point2D(com.ait.lienzo.client.core.types.Point2D) NodeDragMoveHandler(com.ait.lienzo.client.core.event.NodeDragMoveHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ButtonElement(com.google.gwt.dom.client.ButtonElement) LIElement(com.google.gwt.dom.client.LIElement) Element(com.google.gwt.dom.client.Element) NodeDragMoveEvent(com.ait.lienzo.client.core.event.NodeDragMoveEvent) EventTarget(com.google.gwt.dom.client.EventTarget) NativeEvent(com.google.gwt.dom.client.NativeEvent) PostConstruct(javax.annotation.PostConstruct)

Example 7 with EventTarget

use of com.google.gwt.dom.client.EventTarget in project cuba by cuba-platform.

the class CubaSuggestionFieldWidget method handleOnBlur.

protected void handleOnBlur(BlurEvent event) {
    removeStyleName(MODIFIED_STYLENAME);
    if (BrowserInfo.get().isIE()) {
        if (iePreventBlur) {
            textField.setFocus(true);
            iePreventBlur = false;
        } else {
            resetComponentState();
        }
    } else {
        if (!suggestionsPopup.isShowing()) {
            resetComponentState();
            return;
        }
        EventTarget eventTarget = event.getNativeEvent().getRelatedEventTarget();
        if (eventTarget == null) {
            resetComponentState();
            return;
        }
        if (Element.is(eventTarget)) {
            Widget widget = WidgetUtil.findWidget(Element.as(eventTarget), null);
            if (widget != suggestionsContainer) {
                resetComponentState();
            }
        }
    }
}
Also used : EventTarget(com.google.gwt.dom.client.EventTarget)

Example 8 with EventTarget

use of com.google.gwt.dom.client.EventTarget in project ovirt-engine by oVirt.

the class MenuCell method onBrowserEvent.

@Override
public void onBrowserEvent(Context context, Element parent, T value, NativeEvent event, ValueUpdater<T> valueUpdater) {
    super.onBrowserEvent(context, parent, value, event, valueUpdater);
    int eventX = event.getClientX();
    int eventY = event.getClientY();
    // Handle the click event.
    if (BrowserEvents.CLICK.equals(event.getType())) {
        // Ignore clicks that occur outside of the outermost element.
        EventTarget eventTarget = event.getEventTarget();
        if (parent.getFirstChildElement().isOrHasChild(Element.as(eventTarget))) {
            menuPanelPopup.asPopupPanel().showAndFitToScreen(eventX, eventY);
        }
    } else if (BrowserEvents.MOUSEOVER.equals(event.getType())) {
        if (isVisible(value)) {
            // $NON-NLS-1$
            parent.getFirstChildElement().getStyle().setBorderColor("#96B7D6");
        }
    } else {
        // $NON-NLS-1$
        parent.getFirstChildElement().getStyle().setBorderColor("transparent");
    }
}
Also used : EventTarget(com.google.gwt.dom.client.EventTarget)

Example 9 with EventTarget

use of com.google.gwt.dom.client.EventTarget in project GwtMobile by dennisjzh.

the class DragController method fireDragEvent.

protected void fireDragEvent(DragEvent e) {
    if (_capturingDragEventsHandler != null) {
        e.dispatch(_capturingDragEventsHandler);
        return;
    }
    EventTarget target = e.getNativeEvent().getEventTarget();
    Node node = Node.as(target);
    if (!Element.is(node)) {
        // Text node
        node = node.getParentNode();
    }
    if (Element.is(node)) {
        Element ele = Element.as(target);
        int count = 0;
        while (ele != null) {
            for (DragEventsHandler handler : _dragEventHandlers) {
                if (ele.equals(handler.getElement())) {
                    e.dispatch(handler);
                    count++;
                    if (e.getStopPropagation() || count == _dragEventHandlers.size()) {
                        return;
                    }
                }
            }
            ele = ele.getParentElement();
        }
    }
}
Also used : Node(com.google.gwt.dom.client.Node) Element(com.google.gwt.dom.client.Element) EventTarget(com.google.gwt.dom.client.EventTarget) Point(com.gwtmobile.ui.client.utils.Point)

Example 10 with EventTarget

use of com.google.gwt.dom.client.EventTarget in project GwtMobile by dennisjzh.

the class DragController method fireSwipeEvent.

protected void fireSwipeEvent(SwipeEvent e) {
    if (_capturingSwipeEventsHandler != null) {
        e.dispatch(_capturingSwipeEventsHandler);
        return;
    }
    if (_capturingDragEventsHandler != null) {
        return;
    }
    EventTarget target = e.getNativeEvent().getEventTarget();
    Node node = Node.as(target);
    if (!Element.is(node)) {
        // Text node
        node = node.getParentNode();
    }
    if (Element.is(node)) {
        Element ele = Element.as(target);
        int count = 0;
        while (ele != null) {
            for (SwipeEventsHandler handler : _swipeEventHandlers) {
                if (ele.equals(handler.getElement())) {
                    e.dispatch(handler);
                    count++;
                    if (e.getStopPropagation() || count == _swipeEventHandlers.size()) {
                        return;
                    }
                }
            }
            ele = ele.getParentElement();
        }
    }
}
Also used : Node(com.google.gwt.dom.client.Node) Element(com.google.gwt.dom.client.Element) EventTarget(com.google.gwt.dom.client.EventTarget) Point(com.gwtmobile.ui.client.utils.Point)

Aggregations

EventTarget (com.google.gwt.dom.client.EventTarget)16 Element (com.google.gwt.dom.client.Element)11 Point (com.gwtmobile.ui.client.utils.Point)4 NativeEvent (com.google.gwt.dom.client.NativeEvent)3 Node (com.google.gwt.dom.client.Node)2 TableCellElement (com.google.gwt.dom.client.TableCellElement)2 TableRowElement (com.google.gwt.dom.client.TableRowElement)2 TableSectionElement (com.google.gwt.dom.client.TableSectionElement)2 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)2 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)2 NodeDragMoveEvent (com.ait.lienzo.client.core.event.NodeDragMoveEvent)1 NodeDragMoveHandler (com.ait.lienzo.client.core.event.NodeDragMoveHandler)1 Point2D (com.ait.lienzo.client.core.types.Point2D)1 Context (com.google.gwt.cell.client.Cell.Context)1 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)1 ButtonElement (com.google.gwt.dom.client.ButtonElement)1 DivElement (com.google.gwt.dom.client.DivElement)1 LIElement (com.google.gwt.dom.client.LIElement)1 Style (com.google.gwt.dom.client.Style)1 TableElement (com.google.gwt.dom.client.TableElement)1