本文整理汇总了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();
}
}
示例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());
}
}
示例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);
}
示例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);
}
示例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();
}
}
示例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;
}
}
示例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();
}
}
示例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);
}
示例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());
}
}
示例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);
}
示例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();
}
});
}
}
示例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);
}
});
}
}
示例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();
}
});
}
}
示例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(); }
});
}
}
示例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);
}
}
}