Search in sources :

Example 11 with EventTarget

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

the class CheckBoxGroup method onClick.

@Override
public void onClick(ClickEvent e) {
    final EventTarget target = e.getNativeEvent().getEventTarget();
    String targetTagName = ((Element) target.cast()).getTagName().toUpperCase();
    Utils.Console("onClick target " + targetTagName);
    if (targetTagName.equals("LABEL")) {
        // if check box label is click, another (simulated) click event with
        return;
    // check box INPUT as target will fire after this one. So this click event
    // can be safely ignored.
    }
    Element div = Element.as(target);
    while (!div.getNodeName().toUpperCase().equals("SPAN") || div.getParentElement() != this.getElement()) {
        div = div.getParentElement();
        if (div == null) {
            Utils.Console("CheckBoxGroup onClick: span not found");
            return;
        }
    }
    final int index = DOM.getChildIndex(this.getElement(), (com.google.gwt.user.client.Element) div);
    com.google.gwt.user.client.ui.CheckBox checkbox = (com.google.gwt.user.client.ui.CheckBox) _panel.getWidget(index);
    Utils.Console("onClick " + checkbox.getValue());
    if (targetTagName.equals("INPUT")) {
        Utils.Console("onClick value changed");
        // if target is check box INPUT, check box value is
        checkbox.setValue(checkbox.getValue());
    // already changed when click event is fired.
    // just need to set its current value back to the check box
    // to update style.
    } else {
        checkbox.setValue(!checkbox.getValue());
    }
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

        @Override
        public void execute() {
            SelectionChangedEvent selectionChangedEvent = new SelectionChangedEvent(index, target);
            fireEvent(selectionChangedEvent);
        }
    });
}
Also used : Element(com.google.gwt.dom.client.Element) SelectionChangedEvent(com.gwtmobile.ui.client.event.SelectionChangedEvent) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) EventTarget(com.google.gwt.dom.client.EventTarget)

Example 12 with EventTarget

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

the class DragControllerDesktop method onMouseDown.

public void onMouseDown(Event e) {
    EventTarget target = e.getEventTarget();
    boolean preventDefault = true;
    if (Element.is(target)) {
        Element ele = Element.as(target);
        // INPUT element will not get focus if default action is prevented.
        if (Utils.isHtmlFormControl(ele)) {
            ele.focus();
            preventDefault = false;
        }
    }
    if (preventDefault) {
        // prevent default action of selecting text
        e.preventDefault();
        e.stopPropagation();
        onStart(e, new Point(e.getClientX(), e.getClientY()));
    }
}
Also used : Element(com.google.gwt.dom.client.Element) Point(com.gwtmobile.ui.client.utils.Point) EventTarget(com.google.gwt.dom.client.EventTarget)

Example 13 with EventTarget

use of com.google.gwt.dom.client.EventTarget in project activityinfo by bedatadriven.

the class PillCell method onBrowserEvent.

@Override
public void onBrowserEvent(Context context, Element parent, T value, NativeEvent event, ValueUpdater<T> valueUpdater) {
    super.onBrowserEvent(context, parent, value, event, valueUpdater);
    if (CLICK.equals(event.getType())) {
        EventTarget eventTarget = event.getEventTarget();
        if (!Element.is(eventTarget)) {
            return;
        }
        Element element = Element.as(eventTarget);
        if (parent.getFirstChildElement().isOrHasChild(element) && element.hasClassName(AnalysisBundle.INSTANCE.getStyles().handle())) {
            handler.showMenu(element, value);
        }
    }
}
Also used : Element(com.google.gwt.dom.client.Element) EventTarget(com.google.gwt.dom.client.EventTarget)

Example 14 with EventTarget

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

the class AbstractButtonCell method onBrowserEvent.

@Override
public void onBrowserEvent(Context context, Element parent, T value, NativeEvent event, ValueUpdater<T> valueUpdater) {
    super.onBrowserEvent(context, parent, value, event, valueUpdater);
    EventTarget eventTarget = event.getEventTarget();
    if (!Element.is(eventTarget)) {
        return;
    }
    if (BrowserEvents.CLICK.equals(event.getType()) && isEnabled(value)) {
        UICommand command = resolveCommand(value);
        if (command != null) {
            command.execute();
        }
    }
}
Also used : UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) EventTarget(com.google.gwt.dom.client.EventTarget)

Example 15 with EventTarget

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

the class RadioButtonGroup method onClick.

@Override
public void onClick(ClickEvent e) {
    EventTarget target = e.getNativeEvent().getEventTarget();
    String targetTagName = ((Element) target.cast()).getTagName().toUpperCase();
    if (targetTagName.equals("SPAN")) {
        int before = getCheckedIndex();
        super.onClick(e);
        int after = getCheckedIndex();
        Utils.Console("before " + before + " after " + after);
        if (after == -1) {
            RadioButton radio = (RadioButton) getWidget(before);
            if (!radio.getValue()) {
                // cannot un-select a radio button without selecting another one.
                radio.setValue(true);
            }
        } else if (before > -1) {
            RadioButton radio = (RadioButton) getWidget(before);
            radio.setValue(false);
        }
    } else if (targetTagName.equals("INPUT")) {
        super.onClick(e);
        for (int i = 0; i < _panel.getWidgetCount(); i++) {
            RadioButton radio = (RadioButton) getWidget(i);
            radio.setValue(radio.getValue());
        }
    }
}
Also used : EventTarget(com.google.gwt.dom.client.EventTarget)

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