use of com.google.gwt.user.client.ui.TextBox in project gerrit by GerritCodeReview.
the class CopyableLabel method showTextBox.
private void showTextBox() {
if (textBox == null) {
textBox = new TextBox();
textBox.setText(getText());
textBox.setVisibleLength(visibleLen);
textBox.setReadOnly(true);
textBox.addKeyPressHandler(new KeyPressHandler() {
@Override
public void onKeyPress(final KeyPressEvent event) {
if (event.isControlKeyDown() || event.isMetaKeyDown()) {
switch(event.getCharCode()) {
case 'c':
case 'x':
textBox.addKeyUpHandler(new KeyUpHandler() {
@Override
public void onKeyUp(final KeyUpEvent event) {
Scheduler.get().scheduleDeferred(new Command() {
@Override
public void execute() {
hideTextBox();
}
});
}
});
break;
}
}
}
});
textBox.addBlurHandler(new BlurHandler() {
@Override
public void onBlur(final BlurEvent event) {
hideTextBox();
}
});
content.insert(textBox, 1);
}
textLabel.setVisible(false);
textBox.setVisible(true);
Scheduler.get().scheduleDeferred(new Command() {
@Override
public void execute() {
textBox.selectAll();
textBox.setFocus(true);
}
});
}
Aggregations