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);
}
});
}
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()));
}
}
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);
}
}
}
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();
}
}
}
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());
}
}
}
Aggregations