本文整理汇总了C++中KeyEvent::Suppress方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyEvent::Suppress方法的具体用法?C++ KeyEvent::Suppress怎么用?C++ KeyEvent::Suppress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyEvent
的用法示例。
在下文中一共展示了KeyEvent::Suppress方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TriggerKeyEvent
void InputAPI::TriggerKeyEvent(KeyEvent &key)
{
assert(key.eventType != KeyEvent::KeyEventInvalid);
assert(key.handled == false);
// First, we pass the key to the global top level input context, which operates above Qt widget input.
topLevelInputContext.TriggerKeyEvent(key);
if (key.handled) // Convert a Pressed event to a Released event if it was suppressed, so that lower contexts properly let go of the key.
key.eventType = KeyEvent::KeyReleased;
// If the mouse cursor is hidden, we treat each InputContext as if it had TakesKeyboardEventsOverQt true.
// This is because when the mouse cursor is hidden, no key input should go to the main 2D UI window.
// Pass the event to all input contexts in the priority order.
for(auto iter = registeredInputContexts.Begin(); iter != registeredInputContexts.End(); ++iter)
{
InputContextPtr context = iter->Lock();
if (context.Get())// && (!qtWidgetHasKeyboardFocus || context->TakesKeyboardEventsOverQt() || !IsMouseCursorVisible()))
context->TriggerKeyEvent(key);
if (key.handled)
key.eventType = KeyEvent::KeyReleased;
}
// If the mouse cursor is hidden, all key events should go to the 'scene' - In that case, suppress all key events from going to the main 2D Qt window.
if (!IsMouseCursorVisible())
key.Suppress();
}