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 WebGLDemo method createTexture.
private WebGLTexture createTexture(String url) {
// Create the texture object.
final WebGLTexture tex = gl.createTexture();
// Load the image.
final ImageElement img = createImage();
img.setSrc(url);
hookOnLoad(img, new EventHandler() {
@Override
public void onEvent(NativeEvent e) {
// Load image data into the texture object once it's loaded.
gl.bindTexture(TEXTURE_2D, tex);
gl.texImage2D(TEXTURE_2D, 0, RGBA, RGBA, UNSIGNED_BYTE, img);
gl.texParameteri(TEXTURE_2D, TEXTURE_MAG_FILTER, LINEAR);
gl.texParameteri(TEXTURE_2D, TEXTURE_MIN_FILTER, LINEAR);
gl.texParameteri(TEXTURE_2D, TEXTURE_WRAP_S, CLAMP_TO_EDGE);
gl.texParameteri(TEXTURE_2D, TEXTURE_WRAP_T, CLAMP_TO_EDGE);
gl.bindTexture(TEXTURE_2D, null);
}
});
return tex;
}
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;
}
use of com.google.gwt.dom.client.NativeEvent in project gerrit by GerritCodeReview.
the class DiffScreen method onGutterClick.
private GutterClickHandler onGutterClick(final CodeMirror cm) {
return new GutterClickHandler() {
@Override
public void handle(CodeMirror instance, final int line, final String gutterClass, NativeEvent clickEvent) {
if (Element.as(clickEvent.getEventTarget()).hasClassName(getLineNumberClassName()) && clickEvent.getButton() == NativeEvent.BUTTON_LEFT && !clickEvent.getMetaKey() && !clickEvent.getAltKey() && !clickEvent.getCtrlKey() && !clickEvent.getShiftKey()) {
cm.setCursor(Pos.create(line));
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
getCommentManager().newDraftOnGutterClick(cm, gutterClass, line + 1);
}
});
}
}
};
}
use of com.google.gwt.dom.client.NativeEvent in project opennms by OpenNMS.
the class SearchControl method initializeCellAutocompleteWidget.
private void initializeCellAutocompleteWidget() {
final AbstractSafeHtmlRenderer<NodeMarker> renderer = new AbstractSafeHtmlRenderer<NodeMarker>() {
@Override
public SafeHtml render(final NodeMarker marker) {
final SafeHtmlBuilder builder = new SafeHtmlBuilder();
final String search = m_inputBox.getValue();
builder.appendHtmlConstant("<div class=\"autocomplete-label\">");
builder.appendHtmlConstant(marker.getNodeLabel());
builder.appendHtmlConstant("</div>");
String additionalSearchInfo = null;
if (search != null && (search.contains(":") || search.contains("="))) {
final String searchKey = search.replaceAll("[\\:\\=].*$", "").toLowerCase();
LOG.info("searchKey = " + searchKey);
final Map<String, String> props = marker.getProperties();
if ("category".equals(searchKey) || "categories".equals(searchKey)) {
final String catString = props.get("categories");
if (catString != null) {
additionalSearchInfo = catString;
}
}
for (final Map.Entry<String, String> entry : props.entrySet()) {
final String key = entry.getKey().toLowerCase();
final Object value = entry.getValue();
if (key.equals(searchKey) && m_labels.containsKey(key)) {
additionalSearchInfo = m_labels.get(key) + ": " + value;
break;
}
}
}
if (additionalSearchInfo != null) {
builder.appendHtmlConstant("<div class=\"autocomplete-additional-info\">").appendHtmlConstant(additionalSearchInfo).appendHtmlConstant("</div>");
}
return builder.toSafeHtml();
}
};
final AbstractSafeHtmlCell<NodeMarker> cell = new AbstractSafeHtmlCell<NodeMarker>(renderer, "keydown", "click", "dblclick", "touchstart") {
@Override
public void onBrowserEvent(final Context context, final com.google.gwt.dom.client.Element parent, final NodeMarker value, final NativeEvent event, final ValueUpdater<NodeMarker> valueUpdater) {
LOG.info("SearchControl.AutocompleteCell.onBrowserEvent(): context = " + context + ", parent = " + parent + ", value = " + value + ", event = " + event);
if (m_stateManager.handleAutocompleteEvent(event)) {
super.onBrowserEvent(context, parent, value, event, valueUpdater);
}
}
@Override
protected void render(final Context context, final SafeHtml data, final SafeHtmlBuilder builder) {
builder.appendHtmlConstant("<div class=\"autocomplete-entry\">");
if (data != null) {
builder.append(data);
}
builder.appendHtmlConstant("</div>");
}
};
m_autoComplete = new CellList<NodeMarker>(cell);
m_autoComplete.setSelectionModel(m_selectionModel);
m_autoComplete.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.BOUND_TO_SELECTION);
m_autoComplete.setVisible(false);
m_autoComplete.addStyleName("search-autocomplete");
setIdIfMissing(m_autoComplete, "searchControl.autoComplete");
}
Aggregations