本文整理匯總了Java中com.google.gwt.event.dom.client.KeyPressEvent.getUnicodeCharCode方法的典型用法代碼示例。如果您正苦於以下問題:Java KeyPressEvent.getUnicodeCharCode方法的具體用法?Java KeyPressEvent.getUnicodeCharCode怎麽用?Java KeyPressEvent.getUnicodeCharCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.gwt.event.dom.client.KeyPressEvent
的用法示例。
在下文中一共展示了KeyPressEvent.getUnicodeCharCode方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onKeyPress
import com.google.gwt.event.dom.client.KeyPressEvent; //導入方法依賴的package包/類
@Override
public void onKeyPress(KeyPressEvent event) {
try {
int code = event.getUnicodeCharCode();
if (code == '\u002B')
pageView.zoomIn();
else if (code == '\u2212' || code == '\u2010' || code == '\u002D')
pageView.zoomOut();
else if (code == '\u2212' || code == '\u2010' || code == '\u002D')
pageView.zoomOut();
//else if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_PAGEDOWN)
// selectNextObject();
//else if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_PAGEUP)
// selectPreviousObject();
//else
// Window.alert(""+code);
} catch (Exception exc) {
logManager.logError(ERROR_UNSPECIFIED, "Error in onKeyPress()");
exc.printStackTrace();
}
}
示例2: Code
import com.google.gwt.event.dom.client.KeyPressEvent; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
public Code(KeyEvent event){
if (event != null){
if (event instanceof KeyPressEvent){
kP_Event = (KeyPressEvent)event;
} else if (event instanceof KeyDownEvent){
kD_Event = (KeyDownEvent)event;
}
isCtrlDown = event.isControlKeyDown();
isAltDown = event.isAltKeyDown();
isShiftDown = event.isShiftKeyDown();
}
int temp = 0;
if (kP_Event != null){
charCode = kP_Event.getUnicodeCharCode();
} else if (kD_Event != null){
temp = keyCode = kD_Event.getNativeKeyCode();
}
isFunctionKey = false;
for (int k : keyCodes){
if (temp == k) {
isFunctionKey = true;
break;
}
}
}
示例3: toMask
import com.google.gwt.event.dom.client.KeyPressEvent; //導入方法依賴的package包/類
static int toMask(KeyPressEvent event) {
int mask = event.getUnicodeCharCode();
if (mask == 0) {
mask = event.getNativeEvent().getKeyCode();
}
if (event.isControlKeyDown()) {
mask |= KeyCommand.M_CTRL;
}
if (event.isMetaKeyDown()) {
mask |= KeyCommand.M_META;
}
return mask;
}
示例4: hasEnterKeyBeenPressed
import com.google.gwt.event.dom.client.KeyPressEvent; //導入方法依賴的package包/類
public static boolean hasEnterKeyBeenPressed(KeyPressEvent event) {
//GWT BUG: http://code.google.com/p/google-web-toolkit/issues/detail?id=5558
int unicode = event.getUnicodeCharCode();
char code = event.getCharCode();
NativeEvent nativeEvent = event.getNativeEvent();
int keyCode = nativeEvent.getKeyCode();
// AtomTools.log(Level.FINER, "login_passwordbox_keyPress; UnicodeCharCode=\""+unicode+"\" ; keyCode=\""+ keyCode +" ; CharCode=\""+String.valueOf(code)+"\"<endofline>", this);
//if(event.getCharCode() == KeyCodes.KEY_ENTER) {
if(code == '\n' || code == '\r' || (unicode == 0 && keyCode == 13)) {
return true;
}
return false;
}
示例5: Code
import com.google.gwt.event.dom.client.KeyPressEvent; //導入方法依賴的package包/類
/**
* The Code(KeyEvent event) constructor takes a generic KeyEvent and decides whether
* it is a KeyPressEvent or KeyDownEvent. Any relevant information about the event
* is extracted and stored in class variables
* @param event generic KeyEvent
*/
@SuppressWarnings("unchecked")
public Code(KeyEvent event){
if (event != null){
if (event instanceof KeyPressEvent){
kP_Event = (KeyPressEvent)event;
} else if (event instanceof KeyDownEvent){
kD_Event = (KeyDownEvent)event;
}
isCtrlDown = event.isControlKeyDown();
isAltDown = event.isAltKeyDown();
isShiftDown = event.isShiftKeyDown();
}
if (kP_Event != null){
charCode = kP_Event.getUnicodeCharCode();
} else if (kD_Event != null){
keyCode = kD_Event.getNativeKeyCode();
}
isFunctionKey = false;
for (int k : keyCodes){
if (keyCode == k) {
isFunctionKey = true;
break;
}
}
}
示例6: getKeyCode
import com.google.gwt.event.dom.client.KeyPressEvent; //導入方法依賴的package包/類
private static int getKeyCode(final KeyPressEvent event) {
final int code = event.getUnicodeCharCode();
if (code != 0) {
return code;
}
// According to bug #5558, this might confuse '(' and 'down arrow'.
return event.getNativeEvent().getKeyCode();
}