当前位置: 首页>>代码示例>>Java>>正文


Java TextBox.addKeyPressHandler方法代码示例

本文整理汇总了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();
		}
	});
}
 
开发者ID:kuzavas,项目名称:ephesoft,代码行数:43,代码来源:NavBar.java

示例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;

}
 
开发者ID:lsst,项目名称:firefly,代码行数:55,代码来源:PopupUtil.java


注:本文中的com.google.gwt.user.client.ui.TextBox.addKeyPressHandler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。