示例#1
0
        private void Init()
        {
            // 加入焦点监听管理器
            FocusListenManager.AddListener(this);

            // 用事件监听子控件集合的添加或移除
            this.AddingChildControl   += FocusListener_AddingChildControl;
            this.RemovingChildControl += FocusListener_RemovingChildControl;
        }
示例#2
0
        private void ChildControl_GotFocus(object sender, EventArgs e)
        {
            Debug.WriteLine($"[{this.GetType().ToString()}]ChildControl_GotFocus - sender:{((Control)sender).Name}");

            // 回调事件
            GotFocus?.Invoke(sender, e);

            // 修改获得焦点时的记录
            isOnFocus          = true;
            lastOnFocusControl = (Control)sender;

            // 得到焦点后,除了要自身响应焦点事件外,还需要通知所有FocusListener
            FocusListenManager.Broadcast(FocusEvent.Got, this, (Control)sender);
        }
示例#3
0
 static FocusListenManager()
 {
     manager = new FocusListenManager();
 }