本文整理汇总了C++中KeyEvent::GetSource方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyEvent::GetSource方法的具体用法?C++ KeyEvent::GetSource怎么用?C++ KeyEvent::GetSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyEvent
的用法示例。
在下文中一共展示了KeyEvent::GetSource方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: distributeKeyEvent
void Gui::distributeKeyEvent(KeyEvent& keyEvent)
{
WidgetPtr parent = keyEvent.GetSource();
WidgetPtr widget = keyEvent.GetSource();
if (mFocusHandler->GetModalFocused() != NULL
&& !widget->isModalFocused())
{
return;
}
if (mFocusHandler->GetModalMouseInputFocused() != NULL
&& !widget->isModalMouseInputFocused())
{
return;
}
while (parent != NULL)
{
// If the widget has been removed due to input
// cancel the distribution.
if (!Widget::widgetExists(widget))
{
break;
}
parent = widget->GetParent();
if (widget->IsEnabled())
{
std::list<KeyListener*> keyListeners = widget->_getKeyListeners();
// Send the event to all key listeners of the source widget.
for (std::list<KeyListener*>::iterator it = keyListeners.begin();
it != keyListeners.end();
++it)
{
switch (keyEvent.getType())
{
case KeyEvent::PRESSED:
(*it)->keyPressed(keyEvent);
break;
case KeyEvent::RELEASED:
(*it)->keyReleased(keyEvent);
break;
default:
throw GCN_EXCEPTION("Unknown key event type.");
}
}
}
WidgetPtr swap = widget;
widget = parent;
parent = (WidgetPtr)swap->GetParent();
// If a non modal focused widget has been reach
// and we have modal focus cancel the distribution.
if (mFocusHandler->GetModalFocused() != NULL
&& !widget->isModalFocused())
{
break;
}
}
}