本文整理汇总了C++中widget::Ptr::mouseWheelMoved方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::mouseWheelMoved方法的具体用法?C++ Ptr::mouseWheelMoved怎么用?C++ Ptr::mouseWheelMoved使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类widget::Ptr
的用法示例。
在下文中一共展示了Ptr::mouseWheelMoved方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleEvent
//.........这里部分代码省略.........
// Check if a mouse button was released
else if (event.type == sf::Event::MouseButtonReleased)
{
// Check if the left mouse was released
if (event.mouseButton.button == sf::Mouse::Left)
{
// Check if the mouse is on top of an widget
Widget::Ptr widget = mouseOnWidget(static_cast<float>(event.mouseButton.x), static_cast<float>(event.mouseButton.y));
if (widget != nullptr)
widget->leftMouseReleased(static_cast<float>(event.mouseButton.x), static_cast<float>(event.mouseButton.y));
// Tell all the other widgets that the mouse has gone up
for (std::vector<Widget::Ptr>::iterator it = m_Widgets.begin(); it != m_Widgets.end(); ++it)
{
if (*it != widget)
(*it)->mouseNoLongerDown();
}
if (widget != nullptr)
return true;
}
return false;
}
// Check if a key was pressed
else if (event.type == sf::Event::KeyPressed)
{
// Only continue when the character was recognised
if (event.key.code != sf::Keyboard::Unknown)
{
// Check if there is a focused widget
if (m_FocusedWidget)
{
// Check the pressed key
if ((event.key.code == sf::Keyboard::Left)
|| (event.key.code == sf::Keyboard::Right)
|| (event.key.code == sf::Keyboard::Up)
|| (event.key.code == sf::Keyboard::Down)
|| (event.key.code == sf::Keyboard::BackSpace)
|| (event.key.code == sf::Keyboard::Delete)
|| (event.key.code == sf::Keyboard::Space)
|| (event.key.code == sf::Keyboard::Return))
{
// Tell the widget that the key was pressed
m_Widgets[m_FocusedWidget-1]->keyPressed(event.key.code);
}
return true;
}
}
return false;
}
// Check if a key was released
else if (event.type == sf::Event::KeyReleased)
{
// Change the focus to another widget when the tab key was pressed
if (event.key.code == sf::Keyboard::Tab)
return tabKeyPressed();
else
return false;
}
// Also check if text was entered (not a special key)
else if (event.type == sf::Event::TextEntered)
{
// Check if the character that we pressed is allowed
if ((event.text.unicode >= 30) && (event.text.unicode != 127))
{
// Tell the widget that the key was pressed
if (m_FocusedWidget)
{
m_Widgets[m_FocusedWidget-1]->textEntered(event.text.unicode);
return true;
}
}
return false;
}
// Check for mouse wheel scrolling
else if (event.type == sf::Event::MouseWheelMoved)
{
// Find the widget under the mouse
Widget::Ptr widget = mouseOnWidget(static_cast<float>(event.mouseWheel.x), static_cast<float>(event.mouseWheel.y));
if (widget != nullptr)
{
// Send the event to the widget
widget->mouseWheelMoved(event.mouseWheel.delta, event.mouseWheel.x, event.mouseWheel.y);
return true;
}
return false;
}
else // Event is ignored
return false;
}