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


C++ Surface::FocusElement方法代码示例

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


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

示例1: walker

bool
Control::Focus (bool recurse)
{
    if (!IsAttached ())
        return false;

    /* according to msdn, these three things must be true for an element to be focusable:
    *
    * 1. the element must be visible
    * 2. the element must have IsTabStop = true
    * 3. the element must be part of the plugin's visual tree, and must have had its Loaded event fired.
    */

    /*
    * If the current control is not focusable, we walk the visual tree and stop as soon
    * as we find the first focusable child. That then becomes focused
    */
    Types *types = GetDeployment ()->GetTypes ();
    Surface *surface = GetDeployment ()->GetSurface ();
    DeepTreeWalker walker (this);
    while (UIElement *e = walker.Step ()) {
        if (!types->IsSubclassOf (e->GetObjectType (), Type::CONTROL))
            continue;

        Control *c = (Control *)e;
        if (!c->GetIsEnabled ()) {
            if (!recurse)
                return false;

            walker.SkipBranch ();
            continue;
        }

        // A control is focusable if it is attached to a visual tree whose root
        // element has been loaded
        bool loaded = false;
        for (UIElement *check = this; !loaded && check != NULL; check = check->GetVisualParent ())
            loaded |= check->IsLoaded ();

        if (loaded && c->GetRenderVisible () && c->GetIsTabStop ())
            return surface->FocusElement (c);

        if (!recurse)
            return false;
    }
    return false;
}
开发者ID:snorp,项目名称:moon,代码行数:47,代码来源:control.cpp

示例2: if

void
Control::OnPropertyChanged (PropertyChangedEventArgs *args, MoonError *error)
{
    if (args->GetProperty ()->GetOwnerType() != Type::CONTROL) {
        FrameworkElement::OnPropertyChanged (args, error);
        return;
    }

    if (args->GetId () == Control::TemplateProperty) {
        if (GetSubtreeObject ())
            ElementRemoved ((UIElement *) GetSubtreeObject ());
        InvalidateMeasure ();
    }
    else if (args->GetId () == Control::PaddingProperty
             || args->GetId () == Control::BorderThicknessProperty) {
        InvalidateMeasure ();
    } else if (args->GetId () == Control::IsEnabledProperty) {
        if (!args->GetNewValue ()->AsBool ()) {
            Surface *surface = Deployment::GetCurrent ()->GetSurface ();
            if (surface && surface->GetFocusedElement () == this) {
                // Ensure this element loses focus, then try to focus the next suitable element
                surface->FocusElement (NULL);
                TabNavigationWalker::Focus (this, true);
            }
            ReleaseMouseCapture ();
        }
        PropertyChangedEventArgs *pargs = new PropertyChangedEventArgs (args->GetProperty(),
                args->GetId (),
                args->GetOldValue(),
                args->GetNewValue());
        EmitAsync (IsEnabledChangedEvent, pargs);
    } else if (args->GetId () == Control::HorizontalContentAlignmentProperty
               || args->GetId () == Control::VerticalContentAlignmentProperty) {
        InvalidateArrange ();
    }
    NotifyListenersOfPropertyChange (args, error);
}
开发者ID:snorp,项目名称:moon,代码行数:37,代码来源:control.cpp


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