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


Java KeyPressEvent.getCharCode方法代码示例

本文整理汇总了Java中com.google.gwt.event.dom.client.KeyPressEvent.getCharCode方法的典型用法代码示例。如果您正苦于以下问题:Java KeyPressEvent.getCharCode方法的具体用法?Java KeyPressEvent.getCharCode怎么用?Java KeyPressEvent.getCharCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.gwt.event.dom.client.KeyPressEvent的用法示例。


在下文中一共展示了KeyPressEvent.getCharCode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onKeyPress

import com.google.gwt.event.dom.client.KeyPressEvent; //导入方法依赖的package包/类
public void onKeyPress(KeyPressEvent event) {
  ChartState chartInfo = getChartState(event);

  Chart chart = chartInfo.chart;

  int keyCode = event.getCharCode();
  boolean handled = true;
  if (keyCode == KeyCodes.KEY_TAB) {
    handled = handleTabKey((Event)event.getNativeEvent(), chartInfo, keyCode, event.isShiftKeyDown());
  } else if (keyCode == KEY_Z) {
    chart.nextZoom();
  } else if (keyCode == KEY_X) {
    chart.prevZoom();
  } else if (keyCode == KeyCodes.KEY_ENTER) {
    chart.maxZoomToFocus();
  } else {
    handled = false;
  }

  chartInfo.setHandled(handled);
  if (handled) {
      event.stopPropagation();
      event.preventDefault();
  }
}
 
开发者ID:codeaudit,项目名称:gwt-chronoscope,代码行数:26,代码来源:ChartKeyPressHandler.java

示例2: onKeyPress

import com.google.gwt.event.dom.client.KeyPressEvent; //导入方法依赖的package包/类
public void onKeyPress(KeyPressEvent arg0) {
	if (arg0.getCharCode() == KeyCodes.KEY_ENTER) {
		
		Long candidateID = null;
		
		try{
			candidateID = Long.parseLong(addCandidateIdTB.getText());
		}  catch(NumberFormatException e) {
			BallotServer.popError("The Candidate ID must be a number.");
			return;
		}
		
		Communicator.getInstance().getService().addCandidate(electionId, 
				addCandidateNameTB.getText(), candidateID,
				new UpdateCallback());
	}
}
 
开发者ID:nmldiegues,项目名称:easy-vote,代码行数:18,代码来源:ElectionWidget.java

示例3: createCurPageBox

import com.google.gwt.event.dom.client.KeyPressEvent; //导入方法依赖的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

示例4: createCurPageBox

import com.google.gwt.event.dom.client.KeyPressEvent; //导入方法依赖的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

示例5: onKeyPress

import com.google.gwt.event.dom.client.KeyPressEvent; //导入方法依赖的package包/类
/**
 * Fired when a keyboard action generates a character. This occurs after onKeyDown and onKeyUp are fired for the physical key that was pressed.
 *
 * It should be noted that many browsers do not generate keypress events for non-printing keyCode values, such as KEY_ENTER or arrow keys. These keyCodes can be reliably captured either with onKeyDown(Widget, char, int) or onKeyUp(Widget, char, int).
 *
 * Subclasses that override this method must call <tt>super.onKeyPress(sender, keyCode, modifiers)</tt> to ensure that the Widget recieves its events.
 * @param sender the widget that was focused when the event occurred.
 * @see com.google.gwt.user.client.ui.KeyboardListener
 */
public void onKeyPress(KeyPressEvent event) {
    Widget sender = (Widget) event.getSource();
    char keyCode = event.getCharCode();

    // Disallow non-numerics in numeric boxes
    if ((!Character.isDigit(keyCode))
        && (keyCode != (char) KeyCodes.KEY_TAB)
        && (keyCode != (char) KeyCodes.KEY_BACKSPACE)
        && (keyCode != (char) KeyCodes.KEY_DELETE) && (keyCode != (char) KeyCodes.KEY_ENTER)
        && (keyCode != (char) KeyCodes.KEY_HOME) && (keyCode != (char) KeyCodes.KEY_END)
        && (keyCode != (char) KeyCodes.KEY_LEFT) && (keyCode != (char) KeyCodes.KEY_UP)
        && (keyCode != (char) KeyCodes.KEY_RIGHT) && (keyCode != (char) KeyCodes.KEY_DOWN))
    {
        ((TextBox)sender).cancelKey();
    }
}
 
开发者ID:Rise-Vision,项目名称:rva,代码行数:26,代码来源:ColorPickerRGB.java

示例6: onKeyPress

import com.google.gwt.event.dom.client.KeyPressEvent; //导入方法依赖的package包/类
@Override
public void onKeyPress(KeyPressEvent event) {
	char c = event.getCharCode();
	switch (c) {
	case '[':case 'q':
		scale /= KEY_ZOOM_STEP;
		updateZoom();
		break;
	case ']':case 'w':
		scale *= KEY_ZOOM_STEP;
		updateZoom();
		break;
	case '\\': case '1':
		scale = 1;
		updateZoom();
		OMSVGRect viewBox = svg.getViewBox().getBaseVal();
		viewBox.setX(0);
		viewBox.setY(0);
		break;
	}
}
 
开发者ID:rzymek,项目名称:obsolete-web-boards-gwt,代码行数:22,代码来源:SVGZoomAndPanHandler.java

示例7: onKeyPress

import com.google.gwt.event.dom.client.KeyPressEvent; //导入方法依赖的package包/类
@Override
public void onKeyPress(KeyPressEvent event) {
	int keyCode = event.getCharCode();
	if(keyCode == KEY_ENTER) {
		submit();
	}
}
 
开发者ID:Novartis,项目名称:ontobrowser,代码行数:8,代码来源:EditTermPopup.java

示例8: onKeyPress

import com.google.gwt.event.dom.client.KeyPressEvent; //导入方法依赖的package包/类
@Override
public void onKeyPress(KeyPressEvent event) {

	if (isReadOnly() || !isEnabled()) {
		return;
	}

	int keyCode = event.getNativeEvent().getKeyCode();

	switch (keyCode) {
	case KeyCodes.KEY_LEFT:
	case KeyCodes.KEY_RIGHT:
	case KeyCodes.KEY_BACKSPACE:
	case KeyCodes.KEY_DELETE:
	case KeyCodes.KEY_TAB:
	case KeyCodes.KEY_UP:
	case KeyCodes.KEY_DOWN:
		return;
	}

	int index = getCursorPos();
	String previousText = getText();
	String newText;
	if (getSelectionLength() > 0) {
		newText = previousText.substring(0, getCursorPos())
				+ event.getCharCode()
				+ previousText.substring(
						getCursorPos() + getSelectionLength(),
						previousText.length());
	} else {
		newText = previousText.substring(0, index) + event.getCharCode()
				+ previousText.substring(index, previousText.length());
	}
	cancelKey();

	setValue(newText, true);
}
 
开发者ID:mecatran,项目名称:OpenTripPlanner-client-gwt,代码行数:38,代码来源:ValueTextBox.java

示例9: onKeyPress

import com.google.gwt.event.dom.client.KeyPressEvent; //导入方法依赖的package包/类
public void onKeyPress(KeyPressEvent ev) {
    if (submitButton == null) return;
    final int keyCode = ev.getNativeEvent().getKeyCode();
    char charCode = ev.getCharCode();
    if ((keyCode == KeyCodes.KEY_ENTER || charCode == KeyCodes.KEY_ENTER) && ev.getRelativeElement() != null) {
        DeferredCommand.addCommand(new SubmitCommand());
    }
}
 
开发者ID:lsst,项目名称:firefly,代码行数:9,代码来源:Form.java

示例10: createCurPageBox

import com.google.gwt.event.dom.client.KeyPressEvent; //导入方法依赖的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

示例11: onKeyPress

import com.google.gwt.event.dom.client.KeyPressEvent; //导入方法依赖的package包/类
public void onKeyPress(KeyPressEvent ev) {
    final int keyCode = ev.getNativeEvent().getKeyCode();
    char charCode = ev.getCharCode();
    if ((keyCode == KeyCodes.KEY_ENTER || charCode == KeyCodes.KEY_ENTER) && ev.getRelativeElement() != null) {
        DeferredCommand.addCommand(new Command() {
            public void execute() {
                doOK();
            }
        });
    }
}
 
开发者ID:lsst,项目名称:firefly,代码行数:12,代码来源:CatalogSearchDropDown.java

示例12: onKeyPress

import com.google.gwt.event.dom.client.KeyPressEvent; //导入方法依赖的package包/类
public void onKeyPress(KeyPressEvent ev) {
    final char keyCode= ev.getCharCode();
    if (keyCode== KeyCodes.KEY_ENTER || getFireValueChangeOnKeystroke()) {
        DeferredCommand.addCommand(new Command() {
            public void execute() {
                    checkForChange(true);
                }
        });
    }
}
 
开发者ID:lsst,项目名称:firefly,代码行数:11,代码来源:TextBoxInputField.java

示例13: onKeyPress

import com.google.gwt.event.dom.client.KeyPressEvent; //导入方法依赖的package包/类
public void onKeyPress(KeyPressEvent ev) {
    final char keyCode= ev.getCharCode();
    if (keyCode== KeyCodes.KEY_ENTER) {
        DeferredCommand.addCommand(new Command() {
            public void execute() {
                    checkForChange();
                }
        });
    }
}
 
开发者ID:lsst,项目名称:firefly,代码行数:11,代码来源:TextAreaInputField.java

示例14: onKeyPress

import com.google.gwt.event.dom.client.KeyPressEvent; //导入方法依赖的package包/类
public void onKeyPress(KeyPressEvent ev) {
    final int keyCode = ev.getNativeEvent().getKeyCode();
    char charCode = ev.getCharCode();
    if ((keyCode == KeyCodes.KEY_ENTER || charCode == KeyCodes.KEY_ENTER) && ev.getRelativeElement() != null) {
        DeferredCommand.addCommand(new Command() {
            public void execute() { doOK();  }
        });
    }
}
 
开发者ID:lsst,项目名称:firefly,代码行数:10,代码来源:ImageSelectDropDown.java

示例15: onContextKey

import com.google.gwt.event.dom.client.KeyPressEvent; //导入方法依赖的package包/类
@UiHandler("context")
void onContextKey(KeyPressEvent e) {
  if (contextEntireFile.getValue()) {
    char c = e.getCharCode();
    if ('0' <= c && c <= '9') {
      contextEntireFile.setValue(false);
    }
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:10,代码来源:PreferencesBox.java


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