本文整理匯總了Java中com.google.gwt.user.client.ui.TextBox.addKeyPressHandler方法的典型用法代碼示例。如果您正苦於以下問題:Java TextBox.addKeyPressHandler方法的具體用法?Java TextBox.addKeyPressHandler怎麽用?Java TextBox.addKeyPressHandler使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.gwt.user.client.ui.TextBox
的用法示例。
在下文中一共展示了TextBox.addKeyPressHandler方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: NavBar
import com.google.gwt.user.client.ui.TextBox; //導入方法依賴的package包/類
public NavBar(final Table table) {
super();
initWidget(BINDER.createAndBindUi(this));
this.table = table;
Images images = GWT.create(Images.class);
DOM.setInnerHTML(newerButton.getElement(), AbstractImagePrototype.create(images.previousPage()).getHTML());
DOM.setInnerHTML(olderButton.getElement(), AbstractImagePrototype.create(images.nextPage()).getHTML());
DOM.setInnerHTML(upButton.getElement(), AbstractImagePrototype.create(images.upRecord()).getHTML());
DOM.setInnerHTML(downButton.getElement(), AbstractImagePrototype.create(images.downRecord()).getHTML());
//countString = new String();
newerButton.setTitle(LocaleDictionary.get().getConstantValue(LocaleCommonConstants.TITLE_PREVIOUS));
olderButton.setTitle(LocaleDictionary.get().getConstantValue(LocaleCommonConstants.TITLE_NEXT));
upButton.setTitle(LocaleDictionary.get().getConstantValue(LocaleCommonConstants.UP_RECORD));
downButton.setTitle(LocaleDictionary.get().getConstantValue(LocaleCommonConstants.DOWN_RECORD));
searchPageTextBox = new TextBox();
pageNumberValidatableWidget = new ValidatableWidget<TextBox>(searchPageTextBox, true);
pageNumberValidatableWidget.addValidator(new NumberValidator(searchPageTextBox, false, true));
searchPageTextBox.setText("1");
searchPageTextBox.setWidth("30px");
searchPageTextBox.addKeyPressHandler(new KeyPressHandler() {
@Override
public void onKeyPress(KeyPressEvent event) {
String pageNo = searchPageTextBox.getText();
char keyCode = event.getCharCode();
pageNumberValidatableWidget.toggleValidDateBox();
if (keyCode == KeyCodes.KEY_ENTER && checkTextEntered(pageNo) && pageNumberValidatableWidget.validate()) {
moveToEnteredPage(pageNo);
}
}
});
searchPageTextBox.addValueChangeHandler(new ValueChangeHandler<String>() {
@Override
public void onValueChange(ValueChangeEvent<String> arg0) {
pageNumberValidatableWidget.toggleValidDateBox();
}
});
}
示例2: showInputDialog
import com.google.gwt.user.client.ui.TextBox; //導入方法依賴的package包/類
public static BaseDialog showInputDialog(Widget parent,
String msg,
String intialValue,
int preferWidth,
final ClickHandler okHandler,
final ClickHandler cancelHandler) {
final TextBox text = new TextBox();
text.setVisibleLength(preferWidth);
if (!StringUtils.isEmpty(intialValue)) {
text.setText(intialValue);
}
final BaseDialog dialog= new BaseDialog(parent, ButtonType.OK_CANCEL,"Input Dialog",true,null) {
protected void inputComplete() {
if (okHandler!=null) {
okHandler.onClick(new ClickEvent() {
@Override
public Object getSource() {
return text.getText();
}
});
}
}
protected void inputCanceled() {
if (cancelHandler!=null) cancelHandler.onClick(null);
}
};
text.addKeyPressHandler(new KeyPressHandler() {
public void onKeyPress(KeyPressEvent ev) {
final char keyCode= ev.getCharCode();
DeferredCommand.addCommand(new Command() {
public void execute() {
if (keyCode== KeyCodes.KEY_ENTER) {
dialog.getButton(BaseDialog.ButtonID.OK).click();
}
}
});
}
});
VerticalPanel vp = new VerticalPanel();
vp.setSpacing(5);
vp.add(new HTML("<h3>" + msg + "</h3>"));
vp.add(text);
dialog.setWidget(vp);
dialog.setVisible(true);
text.setFocus(true);
return dialog;
}