• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ TouchEvent类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中TouchEvent的典型用法代码示例。如果您正苦于以下问题:C++ TouchEvent类的具体用法?C++ TouchEvent怎么用?C++ TouchEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TouchEvent类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: PLATFORM

void SliderThumbElement::defaultEventHandler(Event* event)
{
    if (!event->isMouseEvent()
#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
        && !event->isTouchEvent()
#endif
        ) {
        HTMLDivElement::defaultEventHandler(event);
        return;
    }

#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
    bool isLeftButton = false;

    if (event->isMouseEvent()) {
        MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
        isLeftButton = mouseEvent->button() == LeftButton;
    }
#else
    MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
    bool isLeftButton = mouseEvent->button() == LeftButton;
#endif
    const AtomicString& eventType = event->type();

    if (eventType == eventNames().mousedownEvent && isLeftButton
#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
            || eventType == eventNames().touchstartEvent
#endif
            ) {
        startDragging();
        return;
    } else if (eventType == eventNames().mouseupEvent && isLeftButton
#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
            || eventType == eventNames().touchendEvent
            || eventType == eventNames().touchcancelEvent
#endif
            ) {
        stopDragging();
        return;
    } else if (eventType == eventNames().mousemoveEvent
#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
            || eventType == eventNames().touchmoveEvent
#endif
            ) {
        if (m_inDragMode)
#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
        {
            if (event->isMouseEvent()) {
                MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
#endif
            setPositionFromPoint(mouseEvent->absoluteLocation());
#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
            } else if (event->isTouchEvent()) {
                TouchEvent* touchEvent = static_cast<TouchEvent*>(event);
                if (touchEvent->touches() && touchEvent->touches()->item(0)) {
                    IntPoint curPoint;
                    curPoint.setX(touchEvent->touches()->item(0)->pageX());
                    curPoint.setY(touchEvent->touches()->item(0)->pageY());
                    setPositionFromPoint(curPoint);
                    // Tell the webview that webkit will handle the following move events
                    event->setDefaultPrevented(true);
                }
            }

        }
#endif
        return;
    }

    HTMLDivElement::defaultEventHandler(event);
}
开发者ID:ACSOP,项目名称:android_external_webkit,代码行数:71,代码来源:SliderThumbElement.cpp


示例2: touchesBegan

void Backtrace::touchesBegan( TouchEvent event )
{
	for( vector<TouchEvent::Touch>::const_iterator touchIt = event.getTouches().begin(); touchIt != event.getTouches().end(); ++touchIt ) {
        mPoints.push_back( touchIt->getPos() );
	}
}
开发者ID:Ahbee,项目名称:Cinder,代码行数:6,代码来源:Backtrace.cpp


示例3: if

WebTouchEventBuilder::WebTouchEventBuilder(const LayoutObject* layoutObject, const TouchEvent& event)
{
    if (event.type() == EventTypeNames::touchstart)
        type = TouchStart;
    else if (event.type() == EventTypeNames::touchmove)
        type = TouchMove;
    else if (event.type() == EventTypeNames::touchend)
        type = TouchEnd;
    else if (event.type() == EventTypeNames::touchcancel)
        type = TouchCancel;
    else {
        ASSERT_NOT_REACHED();
        type = Undefined;
        return;
    }

    timeStampSeconds = event.platformTimeStamp();
    modifiers = event.modifiers();
    cancelable = event.cancelable();
    causesScrollingIfUncanceled = event.causesScrollingIfUncanceled();

    // Currently touches[] is empty, add stationary points as-is.
    for (unsigned i = 0; i < event.touches()->length() && i < static_cast<unsigned>(WebTouchEvent::touchesLengthCap); ++i) {
        touches[i] = toWebTouchPoint(event.touches()->item(i), layoutObject, WebTouchPoint::StateStationary);
        ++touchesLength;
    }
    // If any existing points are also in the change list, we should update
    // their state, otherwise just add the new points.
    addTouchPointsUpdateStateIfNecessary(toWebTouchPointState(event.type()), event.changedTouches(), touches, &touchesLength, layoutObject);
}
开发者ID:howardroark2018,项目名称:chromium,代码行数:30,代码来源:WebInputEventConversion.cpp


示例4: getTimeMS

    void SlidingActor::_newEvent(Event* event)
    {
        if (!_content)
            return;

        TouchEvent* te = safeCast<TouchEvent*>(event);
        //if (te->)
        timeMS tm = getTimeMS();
        switch (te->type)
        {
            case TouchEvent::TOUCH_DOWN:
            {
                _finger = te->index;
                _current = 0;
                _lastIterTime = tm;

                _prev[0].pos = _content->getPosition();
                _prev[0].tm = tm;

                for (int i = 1; i < NUM; ++i)
                    _prev[i].tm = 0;

                _holded = event->target;
                _downPos = te->localPosition;
                _downTime = tm;
            }
            break;

            case TouchEvent::TOUCH_UP:
            {
                if (_ignoreTouchUp)
                {
                    te->stopImmediatePropagation();
                }

                if (_drag.getDragEnabled() && te->index == _finger && _ignoreTouchUp == false)
                {
                    _finger = 0;
                    _downTime = 0;
                    Vector2 pos = _content->getPosition();

                    _holded = 0;

                    const iter* old = 0;
                    const iter* mid = 0;
                    const iter* last = _prev + _current;

                    for (int i = 1; i < NUM; ++i)
                    {
                        int n = (_current + NUM - i) % NUM;
                        if (_prev[n].tm)
                            last = _prev + n;
                        else
                            break;
                        if (!mid && (last->tm + 50 <= tm))
                            mid = last;
                        if (last->tm + 150 <= tm)
                        {
                            old = last;
                            break;
                        }
                    }
                    if (!old)
                        old = last;
                    if (!mid)
                        mid = last;



                    Vector2 midpos = mid->pos;
                    Vector2 dir = pos - midpos;
                    if (dir.sqlength() < 10 * 10)
                        _speed = Vector2(0, 0);
                    else
                    {
                        timeMS v = tm - old->tm;
                        if (!v)
                            return;

                        Vector2 dr = pos - old->pos;

                        Vector2 ns = (dr * 1000.0f) / v;

                        if (_speed.dot(ns) < 0)
                            _speed = ns;
                        else
                            _speed += ns;

                    }


                    if (!_sliding)
                    {
                        _sliding = true;
                    }

                    SlidingEvent sd(SlidingEvent::BEGIN);
                    sd.speed = _speed;
                    dispatchEvent(&sd);
                    _speed = sd.speed;
//.........这里部分代码省略.........
开发者ID:Yahor10,项目名称:oxygine-framework,代码行数:101,代码来源:SlidingActor.cpp


示例5: blockedTouch

 void Flow::blockedTouch(Event* ev)
 {
     TouchEvent* event = safeCast<TouchEvent*>(ev);
     _blockedTouchPosition = event->getPointer()->getPosition();
     _wasTouchBlocked = true;
 }
开发者ID:zmeyc,项目名称:oxygine-flow,代码行数:6,代码来源:flow.cpp


示例6: altKeyAttrGetter

static v8::Handle<v8::Value> altKeyAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
    TouchEvent* imp = V8TouchEvent::toNative(info.Holder());
    return v8Boolean(imp->altKey(), info.GetIsolate());
}
开发者ID:sanyaade-embedded-systems,项目名称:armhf-node-webkit,代码行数:5,代码来源:V8TouchEvent.cpp


示例7: console

void MultiTouchApp::touchesMoved( TouchEvent event )
{
console() << "Moved: " << event << std::endl;
	for( vector<TouchEvent::Touch>::const_iterator touchIt = event.getTouches().begin(); touchIt != event.getTouches().end(); ++touchIt )
		mActivePoints[touchIt->getId()].addPoint( touchIt->getPos() );
}
开发者ID:AKS2346,项目名称:Cinder,代码行数:6,代码来源:MultiTouchApp.cpp


示例8: touchesMoved

void iosAppTestApp::touchesMoved( TouchEvent event )
{
	for( vector<TouchEvent::Touch>::const_iterator touchIt = event.getTouches().begin(); touchIt != event.getTouches().end(); ++touchIt )
		mActivePoints[touchIt->getId()].addPoint( touchIt->getPos() );
}
开发者ID:CinimodStudio,项目名称:Cinder,代码行数:5,代码来源:iosAppTestApp.cpp


示例9: if

WebTouchEventBuilder::WebTouchEventBuilder(const Widget* widget, const WebCore::RenderObject* renderObject, const TouchEvent& event)
{
    if (event.type() == EventTypeNames::touchstart)
        type = TouchStart;
    else if (event.type() == EventTypeNames::touchmove)
        type = TouchMove;
    else if (event.type() == EventTypeNames::touchend)
        type = TouchEnd;
    else if (event.type() == EventTypeNames::touchcancel)
        type = TouchCancel;
    else {
        ASSERT_NOT_REACHED();
        type = Undefined;
        return;
    }

    modifiers = getWebInputModifiers(event);
    timeStampSeconds = event.timeStamp() / millisPerSecond;
    cancelable = event.cancelable();

    addTouchPoints(widget, event.type(), event.touches(), touches, &touchesLength, renderObject);
    addTouchPoints(widget, event.type(), event.changedTouches(), changedTouches, &changedTouchesLength, renderObject);
    addTouchPoints(widget, event.type(), event.targetTouches(), targetTouches, &targetTouchesLength, renderObject);
}
开发者ID:coinpayee,项目名称:blink,代码行数:24,代码来源:WebInputEventConversion.cpp


示例10: onTouch

void WidgetManager::onTouch(TouchEvent& event) {
    for (auto widget : _widgets) {
        if (event.isAccepted()) break;
        widget->onTouch(event);
    }
}
开发者ID:DieHertz,项目名称:android-ios-template,代码行数:6,代码来源:WidgetManager.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TouchList类代码示例发布时间:2022-05-31
下一篇:
C++ TouchButton类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap