Exemple #1
0
 public void SetCaretPos(CaretStruct caret, IntPtr handle, int x, int y)
 {
     if (_focusWindow == handle && caret.Hwnd == _focusWindow)
     {
         Device.BeginInvokeOnMainThread(() =>
         {
             if (caretptr != handle)
             {
                 _inputView.Focus();
             }
             caretptr = handle;
         });
     }
 }
            public void SetCaretPos(CaretStruct caret, IntPtr handle, int x, int y)
            {
                if (_focusWindow == handle && caret.Hwnd == _focusWindow)
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        if (caretptr == handle)
                        {
                            return;
                        }

                        var focusctl = Control.FromHandle(_focusWindow);
                        var p        = focusctl.PointToClient(Form.MousePosition);

                        if (focusctl.ClientRectangle.Contains(p))
                        {
                            // unbind
                            _inputView.Unfocused   -= _inputView_Unfocused;
                            _inputView.TextChanged -= View_TextChanged;
                            _inputView.Completed   -= _inputView_Completed;
                            // set

                            _inputView.Text = focusctl.Text;
                            // rebind
                            _inputView.Completed   += _inputView_Completed;
                            _inputView.TextChanged += View_TextChanged;
                            _inputView.Unfocused   += _inputView_Unfocused;
                            //show
                            _inputView.IsVisible = true;
                            _inputView.Focus();

                            caretptr = handle;
                        }
                    });
                }
            }