zoukankan      html  css  js  c++  java
  • 【msdn wpf forum翻译】获取当前窗口焦点所在的元素

    原文地址: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/6bd7a03a-f0b4-42df-a7f2-5182cf003cb0

    Bialgous回答:
    IInputElement focusedElement = FocusManager.GetFocusedElement(thisWindow);
    有两点需要注意:
    1. 逻辑焦点 != 键盘焦点
        比如当你点开一个菜单时,菜单具有物理焦点
    2. 要想检查得到的这个元素是否有键盘焦点,需检查 IsKeyboardFocused 属性,如果它 == true,则这个元素有键盘焦点

    注:逻辑焦点、物理焦点的概念是什么?不很清楚,请大家赐教:)  ....

    以下是原文:

    Hi, you can always determine which element has logical focus in your application through the FocusManager.GetFocusedElement method -- pass it the window in question and it will return which element has logical focus in that window.  Remember that logical focus != keyboard focus at all times -- toolbars and menus track their own focus so if you are currently interacting with a menu then the menu has physical focus.  But in general, the following code will tell you which element WPF thinks has focus in the window:

    IInputElement focusedElement = FocusManager.GetFocusedElement(thisWindow);

    To determine whether this element has keyboard focus, we can check the IsKeyboardFocused property - if it's set to true, then that element currently has the keyboard focus (as well as being the logical focus for that focus scope).

  • 相关阅读:
    python3 爬取西祠代理IP数据
    电影天堂电影链接爬取
    腾讯招聘信息爬取
    妹子图图片爬取
    我爱我家数据爬取
    今日头条网页图片爬取
    快乐的正则一只
    百思不得姐首页爬取
    雪球网数据爬取
    Python Day79 form表单
  • 原文地址:https://www.cnblogs.com/caoyang/p/1535553.html
Copyright © 2011-2022 走看看