use of com.google.gwt.event.dom.client.KeyPressHandler 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);
}
});
}
use of com.google.gwt.event.dom.client.KeyPressHandler in project kie-wb-common by kiegroup.
the class CustomDataTypeTextBoxTest method testSetup.
@Test
public void testSetup() {
when(textBox.getKeyCodeFromKeyPressEvent(any(KeyPressEvent.class))).thenReturn(64);
when(keyPressEvent.isControlKeyDown()).thenReturn(false);
when(keyPressEvent.isShiftKeyDown()).thenReturn(true);
when(keyPressEvent.getCharCode()).thenReturn('@');
when(textBox.getCursorPos()).thenReturn(4);
when(textBox.getSelectionLength()).thenReturn(0);
when(textBox.getValue()).thenReturn("ab12");
when(textBox.getText()).thenReturn("ab12@");
textBox.setup();
verify(textBox, times(1)).addBlurHandler(blurCaptor.capture());
verify(textBox, times(1)).addKeyPressHandler(keyPressCaptor.capture());
BlurHandler blurHandler = blurCaptor.getValue();
blurHandler.onBlur(blurEvent);
verify(textBox, times(1)).isValidValue("ab12@", true);
verify(textBox, times(1)).makeValidValue("ab12@");
verify(textBox, times(1)).setValue("ab12");
KeyPressHandler keyPressHandler = keyPressCaptor.getValue();
keyPressHandler.onKeyPress(keyPressEvent);
verify(keyPressEvent, times(1)).preventDefault();
verify(textBox, times(1)).isValidValue("ab12@", false);
verify(textBox, times(1)).fireValidationError(ERROR_REMOVED + ": @");
verify(textBox, times(1)).fireValidationError(ERROR_TYPED + ": @");
}
use of com.google.gwt.event.dom.client.KeyPressHandler in project kie-wb-common by kiegroup.
the class VariableNameTextBoxTest method testKeyEnter.
@Test
public void testKeyEnter() {
when(textBox.getKeyCodeFromKeyPressEvent(any(KeyPressEvent.class))).thenReturn(KeyCodes.KEY_ENTER);
when(keyPressEvent.isControlKeyDown()).thenReturn(false);
when(keyPressEvent.isShiftKeyDown()).thenReturn(false);
when(keyPressEvent.getCharCode()).thenReturn((char) 13);
when(textBox.getCursorPos()).thenReturn(4);
when(textBox.getSelectionLength()).thenReturn(0);
when(textBox.getValue()).thenReturn("ab12");
when(textBox.getText()).thenReturn("ab12" + (char) 13);
textBox.setup();
verify(textBox, times(1)).addBlurHandler(blurCaptor.capture());
verify(textBox, times(1)).addKeyPressHandler(keyPressCaptor.capture());
BlurHandler blurHandler = blurCaptor.getValue();
blurHandler.onBlur(blurEvent);
verify(textBox, times(1)).isValidValue("ab12" + (char) 13, true);
verify(textBox, times(1)).makeValidValue("ab12" + (char) 13);
verify(textBox, times(1)).setValue("ab12");
KeyPressHandler keyPressHandler = keyPressCaptor.getValue();
keyPressHandler.onKeyPress(keyPressEvent);
}
use of com.google.gwt.event.dom.client.KeyPressHandler in project kie-wb-common by kiegroup.
the class AttributeValueTextBoxTest method testSetup.
@Test
public void testSetup() {
when(textBox.getKeyCodeFromKeyPressEvent(any(KeyPressEvent.class))).thenReturn(64);
when(keyPressEvent.isControlKeyDown()).thenReturn(false);
when(keyPressEvent.isShiftKeyDown()).thenReturn(true);
when(keyPressEvent.getCharCode()).thenReturn('@');
when(textBox.getCursorPos()).thenReturn(4);
when(textBox.getSelectionLength()).thenReturn(0);
when(textBox.getValue()).thenReturn("ab12");
when(textBox.getText()).thenReturn("ab12@");
textBox.setup();
verify(textBox, times(1)).addBlurHandler(blurCaptor.capture());
verify(textBox, times(1)).addKeyPressHandler(keyPressCaptor.capture());
BlurHandler blurHandler = blurCaptor.getValue();
blurHandler.onBlur(blurEvent);
verify(textBox, times(1)).isValidValue("ab12@", true);
verify(textBox, times(1)).makeValidValue("ab12@");
verify(textBox, times(1)).setValue("ab12");
KeyPressHandler keyPressHandler = keyPressCaptor.getValue();
keyPressHandler.onKeyPress(keyPressEvent);
verify(keyPressEvent, times(1)).preventDefault();
verify(textBox, times(1)).isValidValue("ab12@", false);
verify(textBox, times(1)).fireValidationError(ERROR_REMOVED + ": @");
verify(textBox, times(1)).fireValidationError(ERROR_TYPED + ": @");
}
use of com.google.gwt.event.dom.client.KeyPressHandler in project kie-wb-common by kiegroup.
the class AttributeValueTextBoxTest method testKeyEnter.
@Test
public void testKeyEnter() {
when(textBox.getKeyCodeFromKeyPressEvent(any(KeyPressEvent.class))).thenReturn(KeyCodes.KEY_ENTER);
when(keyPressEvent.isControlKeyDown()).thenReturn(false);
when(keyPressEvent.isShiftKeyDown()).thenReturn(false);
when(keyPressEvent.getCharCode()).thenReturn((char) 13);
when(textBox.getCursorPos()).thenReturn(4);
when(textBox.getSelectionLength()).thenReturn(0);
when(textBox.getValue()).thenReturn("ab12");
when(textBox.getText()).thenReturn("ab12" + (char) 13);
textBox.setup();
verify(textBox, times(1)).addBlurHandler(blurCaptor.capture());
verify(textBox, times(1)).addKeyPressHandler(keyPressCaptor.capture());
BlurHandler blurHandler = blurCaptor.getValue();
blurHandler.onBlur(blurEvent);
verify(textBox, times(1)).isValidValue("ab12" + (char) 13, true);
verify(textBox, times(1)).makeValidValue("ab12" + (char) 13);
verify(textBox, times(1)).setValue("ab12");
KeyPressHandler keyPressHandler = keyPressCaptor.getValue();
keyPressHandler.onKeyPress(keyPressEvent);
}
Aggregations