use of org.rstudio.core.client.dom.DomUtils.NativeEventHandler 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;
}
Aggregations