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


C++ KeyEvent::IsShiftDown方法代码示例

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


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

示例1: OnKeyEvent

    bool FocusManager::OnKeyEvent(const KeyEvent& event)
    {
        // If the focused view wants to process the key event as is, let it be.
        // On Linux we always dispatch key events to the focused view first, so
        // we should not do this check here. See also WidgetGtk::OnKeyEvent().
        if(focused_view_ && focused_view_->SkipDefaultKeyEventProcessing(event))
        {
            return true;
        }

        // Intercept Tab related messages for focus traversal.
        // Note that we don't do focus traversal if the root window is not part of the
        // active window hierarchy as this would mean we have no focused view and
        // would focus the first focusable view.
        HWND top_window = widget_->GetNativeView();
        HWND active_window = ::GetActiveWindow();
        if((active_window==top_window || ::IsChild(active_window, top_window)) &&
            IsTabTraversalKeyEvent(event))
        {
            AdvanceFocus(event.IsShiftDown());
            return false;
        }

        // Intercept arrow key messages to switch between grouped views.
        KeyboardCode key_code = event.GetKeyCode();
        if(focused_view_ && focused_view_->GetGroup()!=-1 &&
            (key_code==VKEY_UP || key_code==VKEY_DOWN ||
            key_code==VKEY_LEFT || key_code==VKEY_RIGHT))
        {
            bool next = (key_code==VKEY_RIGHT || key_code==VKEY_DOWN);
            std::vector<View*> views;
            focused_view_->GetParent()->GetViewsWithGroup(
                focused_view_->GetGroup(), &views);
            std::vector<View*>::const_iterator iter = std::find(views.begin(),
                views.end(), focused_view_);
            DCHECK(iter != views.end());
            int index = static_cast<int>(iter - views.begin());
            index += next ? 1 : -1;
            if(index < 0)
            {
                index = static_cast<int>(views.size()) - 1;
            }
            else if(index >= static_cast<int>(views.size()))
            {
                index = 0;
            }
            SetFocusedViewWithReason(views[index], kReasonFocusTraversal);
            return false;
        }

        // Process keyboard accelerators.
        // If the key combination matches an accelerator, the accelerator is
        // triggered, otherwise the key event is processed as usual.
        Accelerator accelerator(event.GetKeyCode(),
            event.IsShiftDown(),
            event.IsControlDown(),
            event.IsAltDown());
        if(ProcessAccelerator(accelerator))
        {
            // If a shortcut was activated for this keydown message, do not propagate
            // the event further.
            return false;
        }
        return true;
    }
开发者ID:Strongc,项目名称:Chrome_Library,代码行数:65,代码来源:focus_manager.cpp


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