当前位置: 首页>>代码示例>>C++>>正文


C++ Entry::click方法代码示例

本文整理汇总了C++中Entry::click方法的典型用法代码示例。如果您正苦于以下问题:C++ Entry::click方法的具体用法?C++ Entry::click怎么用?C++ Entry::click使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Entry的用法示例。


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

示例1: control

void Submenu::control(int key)
{
    int b;
    do
    {
        b = Input::instance->popButton();
    }
    while (Input::instance->popButton() != -1);
    
    //get mouse position
    const Mouse& mouse = Input::instance->mouse();

    int videoHeight = Video::instance->getResolution().second;
    Vector mousePos = Vector(static_cast<float>(mouse.x), 0.0f, static_cast<float>(videoHeight - mouse.y));

    //adjust active entry depending on up/down keys
    if ((key == GLFW_KEY_DOWN) || (key == GLFW_KEY_UP))
    {
        activateNextEntry(key == GLFW_KEY_DOWN);
        m_menu->m_sound->play(m_menu->m_soundOver);
    }

    if (m_menu->m_mousePrevPos != mousePos)
    {
        //adjust active entry depending on mouse position
        for (size_t i = 0; i < m_entries.size(); i++)
        {
            Entry* currentEntry = m_entries[i];
            if ( (m_previousMousePos != mousePos)
                && currentEntry->isMouseOver(mousePos)
                && (currentEntry->isEnabled()))
            {
                if (m_activeEntry != i)
                {
                    m_menu->m_sound->play(m_menu->m_soundOver);
                }
                m_activeEntry = i;
                break;
            }
        }
        m_menu->m_mousePrevPos = mousePos;
    }

    Entry* currentEntry = m_entries[m_activeEntry];

    
    if (b != -1)
    {
        if (currentEntry->isMouseOver(mousePos))
        {
            currentEntry->click(b);
        }
    }
    else if (key != -1)
    {
        currentEntry->click(key);
    }

    m_previousMousePos = mousePos;
}
开发者ID:mmozeiko,项目名称:Squares3D,代码行数:60,代码来源:menu_submenu.cpp

示例2: control

void Submenu::control()
{
    const Touches& touches = Input::instance->touches();
    if (touches.empty() == false)
    {
        int x = touches.begin()->second.first;
        int y = touches.begin()->second.second;

        int videoHeight = Video::instance->getResolution().second;
        Vector mousePos = Vector(static_cast<float>(x), 0.0f, static_cast<float>(videoHeight - y));

        if (m_menu->m_mousePrevPos != mousePos)
        {
            //adjust active entry depending on mouse position
            for (size_t i = 0; i < m_entries.size(); i++)
            {
                Entry* currentEntry = m_entries[i];
                if ( (m_previousMousePos != mousePos)
                    && currentEntry->isMouseOver(mousePos)
                    && (currentEntry->isEnabled()))
                {
                    if (m_activeEntry != i)
                    {
                        m_menu->m_sound->play(m_menu->m_soundOver);
                    }
                    m_activeEntry = i;
                    Input::instance->waitForRelease();
                    break;
                }
            }
            m_menu->m_mousePrevPos = mousePos;
        }

        Entry* currentEntry = m_entries[m_activeEntry];
        
        if (currentEntry->isMouseOver(mousePos))
        {
            currentEntry->click();
            Input::instance->waitForRelease();
        }

        m_previousMousePos = mousePos;
    }
}
开发者ID:mmozeiko,项目名称:Squares3D-iPad,代码行数:44,代码来源:menu_submenu.cpp


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