use of com.google.gwt.event.dom.client.KeyPressEvent in project gwt-test-utils by gwt-test-utils.
the class TextBoxTest method pressKey.
@Test
public void pressKey() {
// Given
final List<KeyPressEventData> events = new ArrayList<KeyPressEventData>();
TextBox tb = new TextBox();
tb.addKeyPressHandler(new KeyPressHandler() {
public void onKeyPress(KeyPressEvent event) {
KeyPressEventData data = new KeyPressEventData();
data.keyCode = event.getNativeEvent().getKeyCode();
data.charCode = event.getCharCode();
events.add(data);
}
});
// When
Browser.fillText(tb, "gael");
// Then
assertThat(tb.getValue()).isEqualTo("gael");
assertThat(events).hasSize(4);
assertThat(events.get(0).charCode).isEqualTo('g');
assertThat(events.get(0).keyCode).isEqualTo(103);
assertThat(events.get(1).charCode).isEqualTo('a');
assertThat(events.get(1).keyCode).isEqualTo(97);
assertThat(events.get(2).charCode).isEqualTo('e');
assertThat(events.get(2).keyCode).isEqualTo(101);
assertThat(events.get(3).charCode).isEqualTo('l');
assertThat(events.get(3).keyCode).isEqualTo(108);
}
use of com.google.gwt.event.dom.client.KeyPressEvent in project gerrit by GerritCodeReview.
the class MyWatchedProjectsScreen method createWidgets.
protected void createWidgets() {
nameBox = new RemoteSuggestBox(new ProjectNameSuggestOracle());
nameBox.setVisibleLength(50);
nameBox.setHintText(Util.C.defaultProjectName());
nameBox.addSelectionHandler(new SelectionHandler<String>() {
@Override
public void onSelection(SelectionEvent<String> event) {
doAddNew();
}
});
filterTxt = new HintTextBox();
filterTxt.setVisibleLength(50);
filterTxt.setHintText(Util.C.defaultFilter());
filterTxt.addKeyPressHandler(new KeyPressHandler() {
@Override
public void onKeyPress(KeyPressEvent event) {
if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
doAddNew();
}
}
});
addNew = new Button(Util.C.buttonWatchProject());
addNew.addClickHandler(new ClickHandler() {
@Override
public void onClick(final ClickEvent event) {
doAddNew();
}
});
browse = new Button(Util.C.buttonBrowseProjects());
browse.addClickHandler(new ClickHandler() {
@Override
public void onClick(final ClickEvent event) {
// under page header
int top = grid.getAbsoluteTop() - 50;
// Try to place it to the right of everything else, but not
// right justified
int left = 5 + Math.max(grid.getAbsoluteLeft() + grid.getOffsetWidth(), watchesTab.getAbsoluteLeft() + watchesTab.getOffsetWidth());
projectsPopup.setPreferredCoordinates(top, left);
projectsPopup.displayPopup();
}
});
watchesTab = new MyWatchesTable();
delSel = new Button(Util.C.buttonDeleteSshKey());
delSel.addClickHandler(new ClickHandler() {
@Override
public void onClick(final ClickEvent event) {
watchesTab.deleteChecked();
}
});
}
use of com.google.gwt.event.dom.client.KeyPressEvent in project gerrit by GerritCodeReview.
the class CreateGroupScreen method addCreateGroupPanel.
private void addCreateGroupPanel() {
VerticalPanel addPanel = new VerticalPanel();
addPanel.setStyleName(Gerrit.RESOURCES.css().addSshKeyPanel());
addPanel.add(new SmallHeading(AdminConstants.I.headingCreateGroup()));
addTxt = new NpTextBox() {
@Override
public void onBrowserEvent(Event event) {
super.onBrowserEvent(event);
if (event.getTypeInt() == Event.ONPASTE) {
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
if (addTxt.getValue().trim().length() != 0) {
addNew.setEnabled(true);
}
}
});
}
}
};
addTxt.sinkEvents(Event.ONPASTE);
addTxt.setVisibleLength(60);
addTxt.addKeyPressHandler(new KeyPressHandler() {
@Override
public void onKeyPress(KeyPressEvent event) {
if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
doCreateGroup();
}
}
});
addPanel.add(addTxt);
addNew = new Button(AdminConstants.I.buttonCreateGroup());
addNew.setEnabled(false);
addNew.addClickHandler(new ClickHandler() {
@Override
public void onClick(final ClickEvent event) {
doCreateGroup();
}
});
addPanel.add(addNew);
add(addPanel);
new OnEditEnabler(addNew, addTxt);
}
use of com.google.gwt.event.dom.client.KeyPressEvent in project gerrit by GerritCodeReview.
the class CreateProjectScreen method initCreateTxt.
private void initCreateTxt() {
project = new NpTextBox() {
@Override
public void onBrowserEvent(Event event) {
super.onBrowserEvent(event);
if (event.getTypeInt() == Event.ONPASTE) {
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
if (project.getValue().trim().length() != 0) {
create.setEnabled(true);
}
}
});
}
}
};
project.sinkEvents(Event.ONPASTE);
project.setVisibleLength(50);
project.addKeyPressHandler(new KeyPressHandler() {
@Override
public void onKeyPress(KeyPressEvent event) {
if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
doCreateProject();
}
}
});
new OnEditEnabler(create, project);
}
use of com.google.gwt.event.dom.client.KeyPressEvent in project gerrit by GerritCodeReview.
the class NpIntTextBox method init.
private void init() {
addKeyDownHandler(new KeyDownHandler() {
@Override
public void onKeyDown(KeyDownEvent event) {
int code = event.getNativeKeyCode();
onKey(event, code, code);
}
});
addKeyPressHandler(new KeyPressHandler() {
@Override
public void onKeyPress(KeyPressEvent event) {
int charCode = event.getCharCode();
int keyCode = event.getNativeEvent().getKeyCode();
onKey(event, charCode, keyCode);
}
});
}
Aggregations