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


Java KeyPressHandler类代码示例

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

示例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);
}
 
开发者ID:lsst,项目名称:firefly,代码行数:27,代码来源:PagingPanel.java

示例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));
					}
				}
			});
		}
	}
}
 
开发者ID:marat-gainullin,项目名称:platypus-js,代码行数:21,代码来源:EventsExecutor.java

示例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);
}
 
开发者ID:guiguib,项目名称:yaph,代码行数:26,代码来源:LoginPresenter.java

示例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);
						}
					}
				}
			}
		}
	};
}
 
开发者ID:qafedev,项目名称:qafe-platform,代码行数:18,代码来源:EventFactory.java

示例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);
}
 
开发者ID:qafedev,项目名称:qafe-platform,代码行数:25,代码来源:QPagingOptions.java

示例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;
				}
			}
		}
	};
}
 
开发者ID:qafedev,项目名称:qafe-platform,代码行数:24,代码来源:ActivityHelper.java

示例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;
}
 
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:27,代码来源:BeanValidationInitializer.java

示例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);
			}
		}
	});
}
 
开发者ID:jkonert,项目名称:socom,代码行数:22,代码来源:ReportPopup.java

示例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;
    }
}
 
开发者ID:gwtbootstrap3,项目名称:gwtbootstrap3,代码行数:19,代码来源:AbstractForm.java

示例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( );
        }
    } );
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:33,代码来源:NumberBox.java

示例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 );
}
 
开发者ID:ivan-zapreev,项目名称:x-cure-chat,代码行数:29,代码来源:InfoPopupPanel.java

示例13: addKeyPressHandler

import com.google.gwt.event.dom.client.KeyPressHandler; //导入依赖的package包/类
@Override
public HandlerRegistration addKeyPressHandler(final KeyPressHandler handler) {
	return this.addDomHandler(handler,
						 	  KeyPressEvent.getType());
}
 
开发者ID:opendata-euskadi,项目名称:r01fb,代码行数:6,代码来源:TreeView.java

示例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);
		}
	}
}
 
开发者ID:opendata-euskadi,项目名称:r01fb,代码行数:13,代码来源:GWTWidgets.java

示例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);
}
 
开发者ID:lsst,项目名称:firefly,代码行数:34,代码来源:PagingOptions.java


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