本文整理汇总了C++中MotionEvent::copyFrom方法的典型用法代码示例。如果您正苦于以下问题:C++ MotionEvent::copyFrom方法的具体用法?C++ MotionEvent::copyFrom怎么用?C++ MotionEvent::copyFrom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MotionEvent
的用法示例。
在下文中一共展示了MotionEvent::copyFrom方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initializeEventWithHistory
TEST_F(MotionEventTest, CopyFrom_KeepHistory) {
MotionEvent event;
initializeEventWithHistory(&event);
MotionEvent copy;
copy.copyFrom(&event, true /*keepHistory*/);
ASSERT_NO_FATAL_FAILURE(assertEqualsEventWithHistory(&event));
}
示例2: android_view_MotionEvent_nativeCopy
static jint android_view_MotionEvent_nativeCopy(JNIEnv* env, jclass clazz,
jint destNativePtr, jint sourceNativePtr, jboolean keepHistory) {
MotionEvent* destEvent = reinterpret_cast<MotionEvent*>(destNativePtr);
if (!destEvent) {
destEvent = new MotionEvent();
}
MotionEvent* sourceEvent = reinterpret_cast<MotionEvent*>(sourceNativePtr);
destEvent->copyFrom(sourceEvent, keepHistory);
return reinterpret_cast<jint>(destEvent);
}
示例3: nativeSendMotionEvent
static jlong nativeSendMotionEvent(JNIEnv* env, jobject clazz, jlong ptr, jobject eventObj) {
sp<InputQueue> queue = reinterpret_cast<InputQueue*>(ptr);
MotionEvent* originalEvent = android_view_MotionEvent_getNativePtr(env, eventObj);
if (!originalEvent) {
jniThrowRuntimeException(env, "Could not obtain MotionEvent pointer.");
return -1;
}
MotionEvent* event = queue->createMotionEvent();
event->copyFrom(originalEvent, true /* keepHistory */);
queue->enqueueEvent(event);
return reinterpret_cast<jlong>(event);
}
示例4: android_view_MotionEvent_obtainAsCopy
jobject android_view_MotionEvent_obtainAsCopy(JNIEnv* env, const MotionEvent* event) {
jobject eventObj = env->CallStaticObjectMethod(gMotionEventClassInfo.clazz,
gMotionEventClassInfo.obtain);
if (env->ExceptionCheck() || !eventObj) {
ALOGE("An exception occurred while obtaining a motion event.");
LOGE_EX(env);
env->ExceptionClear();
return NULL;
}
MotionEvent* destEvent = android_view_MotionEvent_getNativePtr(env, eventObj);
if (!destEvent) {
destEvent = new MotionEvent();
android_view_MotionEvent_setNativePtr(env, eventObj, destEvent);
}
destEvent->copyFrom(event, true);
return eventObj;
}