當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。