Exemple #1
0
        protected override void OnShown()
        {
            var lol = new WindowDelegate();

            Window.Delegate = lol;

            lol.ResizeRequested += (s, e) => {
                ResizeRequested?.Invoke(this, EventArgs.Empty);
            };

            lol.MovedRequested += (s, e) => {
                MovedRequested?.Invoke(this, EventArgs.Empty);
            };

            lol.LostFocus += (s, e) => {
                LostFocus?.Invoke(this, EventArgs.Empty);
            };

            lol.BecomeMainWindow += (s, e) => {
                OnBecomeMainWindow(this, EventArgs.Empty);
            };

            lol.BecomeKeyWindow += (sender, e) => {
                GotFocus?.Invoke(this, EventArgs.Empty);
            };

            base.OnShown();
        }
 private void ViewImpl_FocusChange(object sender, FocusChangeEventArgs e)
 {
     if (!e.HasFocus)
     {
         LostFocus?.Invoke();
     }
 }
 void NotifyLostFocus()
 {
     if (hasFocus)
     {
         hasFocus = false;
         LostFocus?.Invoke(this, EventArgs.Empty);
     }
 }
Exemple #4
0
 protected override IntPtr WndProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam)
 {
     if (msg == (uint)UnmanagedMethods.WindowsMessage.WM_KILLFOCUS)
     {
         LostFocus?.Invoke();
     }
     return(base.WndProc(hWnd, msg, wParam, lParam));
 }
Exemple #5
0
 private void SetInternalElement(Element value)
 {
     _internalElement             = value;
     InternalJQElement            = new JQElement(_internalElement);
     InternalJQElement.Click     += (sender, args) => Click?.Invoke(this, args);
     InternalJQElement.Focus     += (sender, args) => Focus?.Invoke(this, args);
     InternalJQElement.LostFocus += (sender, args) => LostFocus?.Invoke(this, args);
 }
Exemple #6
0
        internal static void OnFocusChanged(Control control, FocusState focusState)
        {
            if (focusState == FocusState.Unfocused)
            {
                if (control == _focusedElement)
                {
                    _focusedElement = null;

                    if (LostFocus != null)
                    {
                        void OnLostFocus()
                        {
                            // we replay all "lost focus" events
                            LostFocus?.Invoke(null, new FocusManagerLostFocusEventArgs {
                                OldFocusedElement = control
                            });
                        }

                        control.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, OnLostFocus);                         // event is rescheduled, as on UWP
                    }
                }
            }
            else             // Focused
            {
                if (_focusedElement != control)
                {
                    (_focusedElement as Control)?.Unfocus();
                    _focusedElement = control;

                    if (GotFocus != null)
                    {
                        void OnGotFocus()
                        {
                            if (_focusedElement == control)                             // still focused
                            {
                                // we play the gotfocus event only on last/winning control
                                GotFocus?.Invoke(null, new FocusManagerGotFocusEventArgs {
                                    NewFocusedElement = control
                                });
                            }
                        }

                        control.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, OnGotFocus);                         // event is rescheduled, as on UWP
                    }
                }

                _fallbackFocusedElement = control;

#if __ANDROID__
                // Forcefully try to bring the control into view when keyboard is open to accommodate adjust nothing mode
                if (InputPane.GetForCurrentView().Visible)
                {
                    control.StartBringIntoView();
                }
#endif
            }
        }
Exemple #7
0
        internal void OnLostFocus()
        {
            if (hoveredControl != null)
            {
                hoveredControl.selected = false;
                hoveredControl.RaiseOnLostFocus(EventArgs.Empty);
            }

            LostFocus?.Invoke(this, EventArgs.Empty);
        }
Exemple #8
0
 public override void OnWindowFocusChanged(bool hasWindowFocus)
 {
     base.OnWindowFocusChanged(hasWindowFocus);
     if (!_focused || !hasWindowFocus)
     {
         return;
     }
     _focused = false;
     LostFocus?.Invoke(this, EventArgs.Empty);
 }
Exemple #9
0
        private void OnPickerClosed(object sender, EventArgs e)
        {
            var window = sender as TimePickerWindow;

            if (window != null)
            {
                Remove(window);
                LostFocus?.Invoke(this, EventArgs.Empty);
            }
        }
Exemple #10
0
        void Initialize()
        {
            window.DidResize += (s, e) => {
                ResizeRequested?.Invoke(this, EventArgs.Empty);
            };

            window.DidMove += (s, e) => {
                MovedRequested?.Invoke(this, EventArgs.Empty);
            };

            window.DidResignKey += (s, e) => {
                LostFocus?.Invoke(this, EventArgs.Empty);
            };
        }
Exemple #11
0
        public WindowsMediaPlayer()
        {
            InitializeComponent();

            // Editor doesn't keep player settings.
            Player.settings.volume   = 100;
            Player.uiMode            = "full";
            Player.enableContextMenu = false;
            Player.stretchToFit      = true;
            // LostFocus only gets triggered by the COM component.
            Player.LostFocus += (sender, e) => {
                LostFocus?.Invoke(sender, e);
            };
        }
Exemple #12
0
        internal void OnLostFocus()
        {
            if (hoveredControl != null)
            {
                hoveredControl.selected = false;
                hoveredControl.RaiseOnLostFocus(EventArgs.Empty);
                hoveredControl = null;

                Control.lastSelected = null;
            }

            if (LostFocus != null)
            {
                LostFocus.Invoke(this, EventArgs.Empty);
            }
        }
Exemple #13
0
        public virtual void ClearFocus()
        {
            if (!Focused)
            {
                return;
            }

            Focused = false;
            FlushMaterials();
            LostFocus?.Invoke(this, this);

            if (CursorAnimationTimer < 0)
            {
                Engine.Core.State.PauseTimer(CursorAnimationTimer);
            }
        }
Exemple #14
0
        private void Element_LostFocus(object sender, RoutedEventArgs e)
        {
            UIElement element = sender as UIElement;

            if (element == null)
            {
                return;
            }
            hasFocus = false;
            var task = element.Dispatcher.RunIdleAsync((args) => {
                if (!hasFocus)
                {
                    LostFocus?.Invoke(this);
                }
            });
        }
        /// <summary>
        /// コンストラクタ。
        /// </summary>
        public CanvasContext(TextEditorControl control)
        {
            _control = control;
            _control.HandleCreated += (_, __) =>
            {
                _control.Resize     += (s, e) => Resize?.Invoke(new Size2D(_control.ClientSize.Width, _control.ClientSize.Height));
                _control.GotFocus   += (s, e) => GotFocus?.Invoke();
                _control.LostFocus  += (s, e) => LostFocus?.Invoke();
                _control.Paint      += (s, e) => RenderFrame?.Invoke(new RenderingContext(e.Graphics));
                _control.MouseDown  += (s, e) => MouseDown?.Invoke(ToMouseEventInfo(e));
                _control.MouseUp    += (s, e) => MouseUp?.Invoke(ToMouseEventInfo(e));
                _control.MouseMove  += (s, e) => MouseMove?.Invoke(ToMouseEventInfo(e));
                _control.MouseWheel += (s, e) => MouseWheel?.Invoke(ToMouseEventInfo(e));

                Created?.Invoke(new Size2D(_control.ClientSize.Width, _control.ClientSize.Height));
            };
        }
Exemple #16
0
        private static void RaiseLostFocusEvent(object oldFocus)
        {
            void OnLostFocus()
            {
                if (oldFocus is UIElement uiElement)
                {
                    uiElement.RaiseEvent(UIElement.LostFocusEvent, new RoutedEventArgs(uiElement));
                }

                // we replay all "lost focus" events
                LostFocus?.Invoke(null, new FocusManagerLostFocusEventArgs {
                    OldFocusedElement = oldFocus as DependencyObject
                });
            }

            CoreDispatcher.Main.RunAsync(CoreDispatcherPriority.Normal, OnLostFocus);             // event is rescheduled, as on UWP
        }
Exemple #17
0
        private void ChildControl_LostFocus(object sender, EventArgs e)
        {
            // 当控件失去焦点时判断新获得焦点的控件是不是当前监听器下同一组的控件
            // 如果同属一组,则不回调控件焦点丢失的事件委托



            Debug.WriteLine($"[{this.GetType().ToString()}]ChildControl_LostFocus - sender:{((Control)sender).Name}");

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

            // 修改获得焦点时的记录
            isOnFocus = false;

            // 失去焦点后,除了要自身响应焦点事件外,还需要通知所有FocusListener
            //FocusListenManager.Broadcast(FocusEvent.Lost, this, (Control)sender);
        }
Exemple #18
0
 void window_RootKeyChangeFocus(Widget source, EventArgs e)
 {
     if (((RootFocusEventArgs)e).Focus)
     {
         layoutManager.ActiveWindow = this;
         if (GotFocus != null)
         {
             GotFocus.Invoke(this, EventArgs.Empty);
         }
     }
     else
     {
         if (LostFocus != null)
         {
             LostFocus.Invoke(this, EventArgs.Empty);
         }
     }
 }
        /// <summary>
        /// コンストラクタ。
        /// </summary>
        public CanvasContext(TextEditorComponent textEditorComponent, IJSInProcessRuntime jsRuntime, JSEvent jsEvent)
        {
            _textEditorComponent = textEditorComponent;
            _jsRuntime           = jsRuntime;

            _textEditorComponent.Created += size =>
            {
                jsEvent.RegisterActionListener("TextEditorComponent.resize", args => Resize?.Invoke(ToSize(args)));
                jsEvent.RegisterActionListener("TextEditorComponent.mousedown", args => MouseDown?.Invoke(ToMouseState(args)));
                jsEvent.RegisterActionListener("TextEditorComponent.mouseup", args => MouseUp?.Invoke(ToMouseState(args)));
                jsEvent.RegisterActionListener("TextEditorComponent.mousemove", args => MouseMove?.Invoke(ToMouseState(args)));
                jsEvent.RegisterActionListener("TextEditorComponent.mousewheel", args => MouseWheel?.Invoke(ToMouseState(args)));
                jsEvent.RegisterActionListener("TextEditorComponent.render", _ => RenderFrame?.Invoke(new RenderingContext(_textEditorComponent)));
                jsEvent.RegisterActionListener("InputMethod.focusin", args => GotFocus?.Invoke());
                jsEvent.RegisterActionListener("InputMethod.focusout", args => LostFocus?.Invoke());

                Created?.Invoke(size);
            };
        }
Exemple #20
0
        public override void DidEndEditing(NSNotification notification)
        {
            base.DidEndEditing(notification);

            if (ignoreEndEditing)
            {
                ignoreEndEditing = false;
                return;
            }

            PlaceholderAttributedString = MakePlaceholderString(PlaceholderText);

            nint value = ((NSNumber)notification.UserInfo.ValueForKey((NSString)"NSTextMovement")).LongValue;

            if (value == (nint)(long)NSTextMovement.Tab)
            {
                Window.MakeFirstResponder(null);
                LostFocus?.Invoke(this, EventArgs.Empty);
                return;
            }

            if (value == (nint)(long)NSTextMovement.Return)
            {
                if (SelectionActivated != null)
                {
                    SelectionActivated(this, null);
                }
                return;
            }

            // This means we've reached a focus loss event.
            var replacedWith = notification.UserInfo.ValueForKey((NSString)"_NSFirstResponderReplacingFieldEditor");

            if (replacedWith != this && LostFocus != null)
            {
                LostFocus(this, null);
            }
        }
Exemple #21
0
        protected override void OnShown()
        {
            Window.DidResize += (s, e) => {
                ResizeRequested?.Invoke(this, EventArgs.Empty);
            };

            Window.DidMove += (s, e) => {
                MovedRequested?.Invoke(this, EventArgs.Empty);
            };

            Window.DidResignKey += (s, e) => {
                LostFocus?.Invoke(this, EventArgs.Empty);
            };

            Window.DidBecomeMain += (s, e) => {
                OnBecomeMainWindow(this, EventArgs.Empty);
            };

            Window.DidBecomeKey += (sender, e) => {
            };

            base.OnShown();
        }
Exemple #22
0
 protected override void OnLostFocus(RoutedEventArgs e) => LostFocus?.Invoke();
Exemple #23
0
 private void OnLostFocus(object sender, EventArgs e)
 {
     LostFocus?.Invoke(this, e);
 }
Exemple #24
0
 protected internal virtual void OnLostFocus(EventArgs e)
 {
     LostFocus?.Invoke(this, e);
 }
Exemple #25
0
 private void _codeEditor_LostFocus(object sender, Avalonia.Interactivity.RoutedEventArgs e)
 {
     LostFocus?.Invoke(this, EventArgs.Empty);
 }
Exemple #26
0
 internal void Internal_OnLostFocus()
 {
     LostFocus?.Invoke();
     GUI.OnLostFocus();
 }
 public override void DidResignKey(NSNotification notification)
 {
     LostFocus?.Invoke(this, EventArgs.Empty);
 }
 protected internal virtual void OnLostFocus(LostFocusEventArgs args)
 {
     LostFocus?.Invoke(this, args);
 }
Exemple #29
0
 internal void RaiseLostFocus(RoutedEventArgs args) => LostFocus?.Invoke(this, args);
Exemple #30
0
 void Content_LostFocus(object sender, RoutedEventArgs e) => LostFocus?.Invoke(this, EventArgs.Empty);