本文整理汇总了C++中nsCOMPtr::GetKeyCode方法的典型用法代码示例。如果您正苦于以下问题:C++ nsCOMPtr::GetKeyCode方法的具体用法?C++ nsCOMPtr::GetKeyCode怎么用?C++ nsCOMPtr::GetKeyCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsCOMPtr
的用法示例。
在下文中一共展示了nsCOMPtr::GetKeyCode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addKeyEventDataToProperties
nsresult EmbedEventListener::addKeyEventDataToProperties(nsCOMPtr<nsIDOMKeyEvent> keyEvent)
{
// if the initialization failed, don't modify the mProperties
if (!mProperties || !util_StringConstantsAreInitialized()) {
return NS_ERROR_INVALID_ARG;
}
nsresult rv;
// Add modifiers, keys, etc, to the mProperties table
PRUint32 int32Val;
PRBool boolVal;
char buf[20];
jstring strVal;
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
// PENDING(edburns): perhaps use a macro to speed this up?
rv = keyEvent->GetCharCode(&int32Val);
if (NS_SUCCEEDED(rv)) {
buf[0] = (char) int32Val;
buf[1]= nsnull;
strVal = ::util_NewStringUTF(env, buf);
::util_StoreIntoPropertiesObject(env, mProperties, CHAR_CODE,
(jobject) strVal,
(jobject)
&(mOwner->GetWrapperFactory()->shareContext));
}
rv = keyEvent->GetKeyCode(&int32Val);
if (NS_SUCCEEDED(rv)) {
memset(buf, 0, 20);
WC_ITOA(int32Val, buf, 10);
strVal = ::util_NewStringUTF(env, buf);
::util_StoreIntoPropertiesObject(env, mProperties, KEY_CODE,
(jobject) strVal,
(jobject)
&(mOwner->GetWrapperFactory()->shareContext));
}
rv = keyEvent->GetAltKey(&boolVal);
if (NS_SUCCEEDED(rv)) {
strVal = boolVal ? (jstring) TRUE_VALUE : (jstring) FALSE_VALUE;
::util_StoreIntoPropertiesObject(env, mProperties, ALT_KEY,
(jobject) strVal,
(jobject)
&(mOwner->GetWrapperFactory()->shareContext));
}
rv = keyEvent->GetCtrlKey(&boolVal);
if (NS_SUCCEEDED(rv)) {
strVal = boolVal ? (jstring) TRUE_VALUE : (jstring) FALSE_VALUE;
::util_StoreIntoPropertiesObject(env, mProperties, CTRL_KEY,
(jobject) strVal,
(jobject)
&(mOwner->GetWrapperFactory()->shareContext));
}
rv = keyEvent->GetShiftKey(&boolVal);
if (NS_SUCCEEDED(rv)) {
strVal = boolVal ? (jstring) TRUE_VALUE : (jstring) FALSE_VALUE;
::util_StoreIntoPropertiesObject(env, mProperties, SHIFT_KEY,
(jobject) strVal,
(jobject)
&(mOwner->GetWrapperFactory()->shareContext));
}
rv = keyEvent->GetMetaKey(&boolVal);
if (NS_SUCCEEDED(rv)) {
strVal = boolVal ? (jstring) TRUE_VALUE : (jstring) FALSE_VALUE;
::util_StoreIntoPropertiesObject(env, mProperties, META_KEY,
(jobject) strVal,
(jobject)
&(mOwner->GetWrapperFactory()->shareContext));
}
return rv;
}