use of com.google.gwt.dom.client.NativeEvent in project rstudio by rstudio.
the class InlineToolbarButton method addClickHandler.
@Override
public HandlerRegistration addClickHandler(ClickHandler clickHandler) {
/*
* When we directly subscribe to this widget's ClickEvent, sometimes the
* click gets ignored (inconsistent repro but it happens enough to be
* annoying). Doing it this way fixes it.
*/
hasHandlers_.addHandler(ClickEvent.getType(), clickHandler);
final HandlerRegistration mouseDown = addDomHandler(new MouseDownHandler() {
public void onMouseDown(MouseDownEvent event) {
event.preventDefault();
event.stopPropagation();
down_ = true;
}
}, MouseDownEvent.getType());
final HandlerRegistration mouseOut = addDomHandler(new MouseOutHandler() {
public void onMouseOut(MouseOutEvent event) {
event.preventDefault();
event.stopPropagation();
down_ = false;
}
}, MouseOutEvent.getType());
final HandlerRegistration mouseUp = addDomHandler(new MouseUpHandler() {
public void onMouseUp(MouseUpEvent event) {
event.preventDefault();
event.stopPropagation();
if (down_) {
down_ = false;
NativeEvent clickEvent = Document.get().createClickEvent(1, event.getScreenX(), event.getScreenY(), event.getClientX(), event.getClientY(), event.getNativeEvent().getCtrlKey(), event.getNativeEvent().getAltKey(), event.getNativeEvent().getShiftKey(), event.getNativeEvent().getMetaKey());
DomEvent.fireNativeEvent(clickEvent, hasHandlers_);
}
}
}, MouseUpEvent.getType());
return new HandlerRegistration() {
public void removeHandler() {
mouseDown.removeHandler();
mouseOut.removeHandler();
mouseUp.removeHandler();
}
};
}
use of com.google.gwt.dom.client.NativeEvent in project rstudio by rstudio.
the class AceEditorBackgroundLinkHighlighter method onMouseUp.
@Override
public void onMouseUp(MouseUpEvent mouseUpEvent) {
// clicks handled in 'onAceClick' for OS X web mode
if (BrowseCap.isMacintosh() && !BrowseCap.isMacintoshDesktop())
return;
NativeEvent event = mouseUpEvent.getNativeEvent();
if (!isRequiredClickModifier(event))
return;
MarkerRegistration marker = getTargetedMarker(event);
if (marker == null)
return;
boolean hasMouseMoved = Math.abs(event.getClientX() - mouseTracker_.getLastMouseX()) >= 2 || Math.abs(event.getClientY() - mouseTracker_.getLastMouseY()) >= 2;
if (hasMouseMoved)
return;
event.stopPropagation();
event.preventDefault();
endDetectClickTarget();
String url = editor_.getTextForRange(marker.getRange());
navigateToUrl(url);
}
use of com.google.gwt.dom.client.NativeEvent in project rstudio by rstudio.
the class ChunkOptionsPopupPanel method makeInputBox.
private TextBox makeInputBox(final String option, final boolean enquote) {
final TextBox box = new TextBox();
box.getElement().setAttribute("placeholder", "Default");
box.setWidth("40px");
DomUtils.addKeyHandlers(box, new NativeEventHandler() {
@Override
public void onNativeEvent(NativeEvent event) {
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
String text = box.getText().trim();
boolean isEmpty = StringUtil.isNullOrEmpty(text);
if (enquote && !isEmpty) {
text = StringUtil.ensureQuoted(text);
text = text.replaceAll("\\\\", "\\\\\\\\");
}
if (isEmpty)
unset(option);
else
set(option, text);
synchronize();
}
});
}
});
return box;
}
use of com.google.gwt.dom.client.NativeEvent in project rstudio by rstudio.
the class StatusBarElementWidget method click.
public void click() {
NativeEvent evt = Document.get().createMouseDownEvent(0, 0, 0, 0, 0, false, false, false, false, 0);
ClickEvent.fireNativeEvent(evt, this);
}
use of com.google.gwt.dom.client.NativeEvent in project playn by threerings.
the class HtmlTouch method toEvents.
private Event.Impl[] toEvents(NativeEvent nativeEvent, Events.Flags flags) {
// Convert the JsArray<Native Touch> to an array of Touch.Events
JsArray<com.google.gwt.dom.client.Touch> nativeTouches = nativeEvent.getChangedTouches();
int nativeTouchesLen = nativeTouches.length();
Event.Impl[] touches = new Event.Impl[nativeTouchesLen];
for (int t = 0; t < nativeTouchesLen; t++) {
com.google.gwt.dom.client.Touch touch = nativeTouches.get(t);
float x = touch.getRelativeX(rootElement);
float y = touch.getRelativeY(rootElement);
Point xy = platform.graphics().transformMouse(x, y);
int id = getTouchIdentifier(nativeEvent, t);
touches[t] = new Event.Impl(flags, PlayN.currentTime(), xy.x, xy.y, id);
}
return touches;
}
Aggregations