本文整理汇总了Java中com.google.gwt.event.dom.client.KeyPressHandler类的典型用法代码示例。如果您正苦于以下问题:Java KeyPressHandler类的具体用法?Java KeyPressHandler怎么用?Java KeyPressHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
KeyPressHandler类属于com.google.gwt.event.dom.client包,在下文中一共展示了KeyPressHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addEnterTarget
import com.google.gwt.event.dom.client.KeyPressHandler; //导入依赖的package包/类
/**
* Adds a {@link KeyPressHandler} to the specified widget which calls {@link Button#click()} on <code>targetButton</code>
* when the Enter key is pressed.
* @param widget widget to add the key handler to
* @param targetButton target button to activate when the enter key is pressed
*/
public static void addEnterTarget( final HasKeyPressHandlers widget, final Button targetButton ) {
widget.addKeyPressHandler( new KeyPressHandler() {
@Override
public void onKeyPress( final KeyPressEvent event ) {
if ( event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER )
targetButton.click();
}
} );
}
示例2: createCurPageBox
import com.google.gwt.event.dom.client.KeyPressHandler; //导入依赖的package包/类
/**
* Create a box that holds the current page.
*/
private void createCurPageBox() {
// Setup the widget
curPageBox.setWidth("3em");
curPageBox.setText("1");
curPageBox.setTextAlignment(TextBoxBase.ALIGN_RIGHT);
// Disallow non-numeric pages
KeyPressHandler handler = new KeyPressHandler() {
public void onKeyPress(KeyPressEvent event) {
int keyCode = event.getNativeEvent().getKeyCode();
char charCode = event.getCharCode();
if (keyCode == KeyCodes.KEY_ENTER) {
PagingPanel.this.table.gotoPage(getPagingBoxValue(), false);
} else if (charCode != 0 && !Character.isDigit(charCode)) {
curPageBox.cancelKey();
}
}
};
// Add the handler
curPageBox.addKeyPressHandler(handler);
}
示例3: setKeyTyped
import com.google.gwt.event.dom.client.KeyPressHandler; //导入依赖的package包/类
public void setKeyTyped(JavaScriptObject aValue) {
if (keyTyped != aValue) {
if (keyTypedReg != null) {
keyTypedReg.removeHandler();
keyTypedReg = null;
}
keyTyped = aValue;
if (keyTyped != null && component instanceof HasKeyPressHandlers) {
keyTypedReg = ((HasKeyPressHandlers) component).addKeyPressHandler(new KeyPressHandler() {
@Override
public void onKeyPress(KeyPressEvent event) {
if (keyTyped != null) {
event.stopPropagation();
executeEvent(keyTyped, EventsPublisher.publish(event));
}
}
});
}
}
}
示例4: bind
import com.google.gwt.event.dom.client.KeyPressHandler; //导入依赖的package包/类
public void bind() {
RootPanel.get("container").add(getView().asWidget());
getView().asWidget().setVisible(false);
view.getLoginButton().addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent arg0) {
login();
}
});
KeyPressHandler handler = new KeyPressHandler() {
@Override
public void onKeyPress(KeyPressEvent event) {
// Si on appuie sur "Entrée"
if (KeyCodes.KEY_ENTER == event.getNativeEvent().getKeyCode())
login();
}
};
getView().getLoginKeyPress().addKeyPressHandler(handler);
getView().getPasswdKeyPress().addKeyPressHandler(handler);
getView().asWidget().setVisible(true);
}
示例5: createOnKeyPressListener
import com.google.gwt.event.dom.client.KeyPressHandler; //导入依赖的package包/类
public static KeyPressHandler createOnKeyPressListener(final EventListenerGVO ev, final List<InputVariableGVO> input) {
return new KeyPressHandler() {
public void onKeyPress(KeyPressEvent event) {
if (ev.getParameterList() != null) {
Iterator<ParameterGVO> itr = ev.getParameterList().iterator();
while (itr.hasNext()) {
ParameterGVO parameter = itr.next();
if (parameter != null) {
if (KeyBoardHelper.isKeyInput(parameter.getName(), parameter.getValue(), Character.toString(event.getCharCode()))) {
CallbackHandler.createCallBack(event.getSource(), QAMLConstants.EVENT_ONKEYPRESS, ev, input);
}
}
}
}
}
};
}
示例6: createCurPageBox
import com.google.gwt.event.dom.client.KeyPressHandler; //导入依赖的package包/类
/**
* Create a box that holds the current page.
*/
private void createCurPageBox() {
// Setup the widget
curPageBox.setWidth("3em");
curPageBox.setText("1");
curPageBox.setTextAlignment(TextBoxBase.ALIGN_RIGHT);
// Disallow non-numeric pages
KeyPressHandler handler = new KeyPressHandler() {
public void onKeyPress(KeyPressEvent event) {
char charCode = event.getCharCode();
if (charCode == KeyCodes.KEY_ENTER) {
QPagingOptions.this.table.gotoPage(getPagingBoxValue(), false);
} else if (!Character.isDigit(charCode) && (charCode != KeyCodes.KEY_TAB) && (charCode != KeyCodes.KEY_BACKSPACE) && (charCode != KeyCodes.KEY_DELETE) && (charCode != KeyCodes.KEY_ENTER) && (charCode != KeyCodes.KEY_HOME) && (charCode != KeyCodes.KEY_END) && (charCode != KeyCodes.KEY_LEFT) && (charCode != KeyCodes.KEY_UP) && (charCode != KeyCodes.KEY_RIGHT) && (charCode != KeyCodes.KEY_DOWN)) {
curPageBox.cancelKey();
}
}
};
// Add the handler
curPageBox.addKeyPressHandler(handler);
}
示例7: createKeyPressHandler
import com.google.gwt.event.dom.client.KeyPressHandler; //导入依赖的package包/类
private static KeyPressHandler createKeyPressHandler(final ComponentGVO componentGVO, final EventListenerGVO eventGVO, final NotifyHandler notifyHandler, final String windowId, final String context, final AbstractActivity activity) {
return new KeyPressHandler() {
@Override
public void onKeyPress(KeyPressEvent event) {
if (eventGVO.getParameterList() == null) {
return;
}
Iterator<ParameterGVO> itrParameter = eventGVO.getParameterList().iterator();
while (itrParameter.hasNext()) {
ParameterGVO parameterGVO = itrParameter.next();
if (parameterGVO == null) {
continue;
}
if (KeyBoardHelper.isKeyInput(parameterGVO.getName(), parameterGVO.getValue(), Character.toString(event.getCharCode()))) {
UIObject widget = (UIObject)event.getSource();
List<InputVariableGVO> inputVariables = eventGVO.getInputvariablesList();
handleEvent(componentGVO, widget, eventGVO, event, QAMLConstants.EVENT_ONKEYPRESS, inputVariables, notifyHandler, windowId, context, activity);
break;
}
}
}
};
}
示例8: BeanValidationInitializer
import com.google.gwt.event.dom.client.KeyPressHandler; //导入依赖的package包/类
/**
* constructor.
*
* @param pcommitOnReturnHandler commit on return handler
* @param pvalidateOnKeyUpHandler on key up handler
* @param pvalidateOnVueChangeHandler on vue change handler
* @param pvalueChangeHandler value change handler
* @param pcheckTime enumeration which describes when to do the check
* @param psubmitOnReturn submit form if return is pressed in a input field
*/
public BeanValidationInitializer(final KeyPressHandler pcommitOnReturnHandler,
final KeyUpHandler pvalidateOnKeyUpHandler,
final ValueChangeHandler<?> pvalidateOnVueChangeHandler,
final ValueChangeHandler<?> pvalueChangeHandler, final CheckTimeEnum pcheckTime,
final boolean psubmitOnReturn) {
super();
this.commitOnReturnHandler = psubmitOnReturn ? pcommitOnReturnHandler : null;
this.validateOnKeyUpHandler =
pcheckTime == CheckTimeEnum.ON_KEY_UP ? pvalidateOnKeyUpHandler : null;
this.validateOnVueChangeHandler =
pcheckTime == CheckTimeEnum.ON_CHANGE || pcheckTime == CheckTimeEnum.ON_KEY_UP
? pvalidateOnVueChangeHandler
: null;
this.valueChangeHandler = pvalueChangeHandler;
this.checkTime = pcheckTime;
}
示例9: limitArea
import com.google.gwt.event.dom.client.KeyPressHandler; //导入依赖的package包/类
private void limitArea() {
reportTextArea.getElement().setAttribute("maxlength", String.valueOf(MAX_REPORT_LENGTH));
reportTextArea.addKeyPressHandler(new KeyPressHandler() {
@Override
public void onKeyPress(KeyPressEvent event) {
int size = reportTextArea.getText().length();
textLength.setText(String.valueOf(MAX_REPORT_LENGTH-size));
if(size == MAX_REPORT_LENGTH) {
Animation a = new Animation() {
@Override
protected void onUpdate(double progress) {
String rgbvalue = "rgb(" + ((int)((1-progress)*255)) + ",0,0)";
textLengthPanel.getElement().getStyle().setProperty("color", rgbvalue);
}
};
a.run(1000);
}
}
});
}
示例10: setSubmitOnEnter
import com.google.gwt.event.dom.client.KeyPressHandler; //导入依赖的package包/类
public void setSubmitOnEnter(boolean submitOnEnter) {
if (submitOnEnter) {
if (submitOnEnterRegistration == null)
submitOnEnterRegistration = addDomHandler(new KeyPressHandler() {
@Override
public void onKeyPress(KeyPressEvent event) {
if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
if (validate()) {
fireSubmitEvent();
}
}
}
}, KeyPressEvent.getType());
} else if (submitOnEnterRegistration != null) {
submitOnEnterRegistration.removeHandler();
submitOnEnterRegistration = null;
}
}
示例11: NumberBox
import com.google.gwt.event.dom.client.KeyPressHandler; //导入依赖的package包/类
public NumberBox() {
setStyleName("gwt-SuggestBox");
setWidth("100px");
getElement().getStyle().setTextAlign(TextAlign.RIGHT);
addKeyPressHandler(new KeyPressHandler() {
@Override
public void onKeyPress(KeyPressEvent event) {
if (!isEnabled() || isReadOnly()) return;
int keyCode = event.getNativeEvent().getKeyCode();
switch (keyCode) {
case KeyCodes.KEY_BACKSPACE:
case KeyCodes.KEY_DELETE:
case KeyCodes.KEY_ESCAPE:
case KeyCodes.KEY_RIGHT:
case KeyCodes.KEY_LEFT:
case KeyCodes.KEY_TAB:
return;
}
if (isDecimal() && event.getCharCode() == '.' && !getValue().contains(".")) return;
if (isNegative() && event.getCharCode() == '-' && !getValue().contains("-") && (getCursorPos() == 0 || getSelectionLength() == getValue().length()))
return;
if (Character.isDigit(event.getCharCode()))
return;
cancelKey( );
}
} );
}
示例12: InfoPopupPanel
import com.google.gwt.event.dom.client.KeyPressHandler; //导入依赖的package包/类
protected InfoPopupPanel(boolean autoHide, boolean modal){
super(autoHide, modal);
//Register the popup in the list of popups eligible for closing on user-logout
SiteManagerUI.getInstance().registerPopup( this );
//Set Animation ON
this.setAnimationEnabled( true );
//Add the close by escape handler
this.addDomHandler( new KeyPressHandler(){
public void onKeyPress( KeyPressEvent event ){
NativeEvent nativeEvent = event.getNativeEvent();
if( ( nativeEvent.getKeyCode() == KeyCodes.KEY_ESCAPE ) ) {
hide();
}
}
}, KeyPressEvent.getType() );
//Set the width of the panel
//this.setWidth("25%");
//Adding decorator panel inside the pop-up because
//we want the panel to have rounded borders.
decoratedPanel.setSize( "100%", "100%");
decoratedPanel.setStyleName( CommonResourcesContainer.INFO_POPUP_STYLE_NAME );
this.add( decoratedPanel );
}
示例13: addKeyPressHandler
import com.google.gwt.event.dom.client.KeyPressHandler; //导入依赖的package包/类
@Override
public HandlerRegistration addKeyPressHandler(final KeyPressHandler handler) {
return this.addDomHandler(handler,
KeyPressEvent.getType());
}
示例14: addKeyPressHandler
import com.google.gwt.event.dom.client.KeyPressHandler; //导入依赖的package包/类
/**
* Sets the KeyPress() event handler in many widgets
* @param handler the handler
* @param widgets the widgets
*/
public static void addKeyPressHandler(final KeyPressHandler handler,final HasKeyPressHandlers... widgets) {
if (handler != null && widgets != null && widgets.length > 0) {
for (HasKeyPressHandlers w : widgets) {
if (w != null) w.addKeyPressHandler(handler);
}
}
}
示例15: createCurPageBox
import com.google.gwt.event.dom.client.KeyPressHandler; //导入依赖的package包/类
/**
* Create a box that holds the current page.
*/
private void createCurPageBox() {
// Setup the widget
curPageBox.setWidth("3em");
curPageBox.setText("1");
curPageBox.setTextAlignment(TextBoxBase.ALIGN_RIGHT);
// Disallow non-numeric pages
KeyPressHandler handler = new KeyPressHandler() {
public void onKeyPress(KeyPressEvent event) {
char charCode = event.getCharCode();
if (charCode == KeyCodes.KEY_ENTER) {
PagingOptions.this.imageGridPanel.getImageGrid().gotoPage(getPagingBoxValue(), false);
} else if (!Character.isDigit(charCode)
&& (charCode != KeyCodes.KEY_TAB)
&& (charCode != KeyCodes.KEY_BACKSPACE)
&& (charCode != KeyCodes.KEY_DELETE)
&& (charCode != KeyCodes.KEY_ENTER)
&& (charCode != KeyCodes.KEY_HOME)
&& (charCode != KeyCodes.KEY_END)
&& (charCode != KeyCodes.KEY_LEFT) && (charCode != KeyCodes.KEY_UP)
&& (charCode != KeyCodes.KEY_RIGHT)
&& (charCode != KeyCodes.KEY_DOWN)) {
curPageBox.cancelKey();
}
}
};
// Add the handler
curPageBox.addKeyPressHandler(handler);
}