コード例 #1
0
        public virtual void SetFocus()
        {
            if (Focused)
            {
                return;
            }

            Focused    = true;
            DrawCursor = true;
            FlushMaterials();
            GotFocus?.Invoke(this, this);

            if (!string.IsNullOrEmpty(FocusSound))
            {
                SoundManager.PlaySound(FocusSound);
            }

            if (CursorAnimationTimer < 0)
            {
                CursorAnimationTimer = Engine.Core.State.AddTimer(CursorBlinkRate, true, ToggleCursorDraw);
            }
            else
            {
                Engine.Core.State.ResumeTimer(CursorAnimationTimer);
            }
        }
コード例 #2
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();
        }
コード例 #3
0
 void NotifyGotFocus()
 {
     if (!hasFocus)
     {
         hasFocus = true;
         lastViewFocused.SetTarget(this);
         GotFocus?.Invoke(this, EventArgs.Empty);
     }
 }
コード例 #4
0
ファイル: FocusManager.cs プロジェクト: yashasvibajpai/uno
        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
            }
        }
コード例 #5
0
 private void SelectList_Touch(object sender, TouchEventArgs e)
 {
     e.Handled = false;
     if (e.Event.Action != MotionEventActions.Up || _focused)
     {
         return;
     }
     TextBase.CurrentFocus?.Blur(true);
     _focused = true;
     GotFocus?.Invoke(this, EventArgs.Empty);
 }
コード例 #6
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);
        }
コード例 #7
0
        private void ShowTimePickerWindow()
        {
            int x = 0;
            int y = 0;

            GdkWindow.GetOrigin(out x, out y);
            y += Allocation.Height;

            var picker = new TimePickerWindow();

            picker.Move(x, y);
            picker.CurrentTime    = CurrentTime;
            picker.OnTimeChanged += OnPopupTimeChanged;
            picker.Destroyed     += OnPickerClosed;
            GotFocus?.Invoke(this, EventArgs.Empty);
        }
コード例 #8
0
        private static void RaiseGotFocusEvent(object newFocus)
        {
            void OnGotFocus()
            {
                if (newFocus is UIElement uiElement)
                {
                    uiElement.RaiseEvent(UIElement.GotFocusEvent, new RoutedEventArgs(uiElement));
                }

                GotFocus?.Invoke(null, new FocusManagerGotFocusEventArgs {
                    NewFocusedElement = newFocus as DependencyObject
                });
            }

            CoreDispatcher.Main.RunAsync(CoreDispatcherPriority.Normal, OnGotFocus);             // event is rescheduled, as on UWP
        }
コード例 #9
0
        /// <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));
            };
        }
コード例 #10
0
ファイル: MDIDialog.cs プロジェクト: AnomalousMedical/Engine
 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);
         }
     }
 }
コード例 #11
0
        /// <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);
            };
        }
コード例 #12
0
 void OnEntryFocused(object sender, EventArgs e)
 {
     ShowPickerWindow();
     GotFocus?.Invoke(this, EventArgs.Empty);
 }
コード例 #13
0
 /// <summary>
 /// Called when the panel has got focus.
 /// </summary>
 /// <remarks>
 /// The base method triggers the <see cref="GotFocus"/> event.
 /// </remarks>
 public virtual void UIGotFocus()
 {
     GotFocus?.Invoke(this, null);
 }
コード例 #14
0
 protected internal virtual void OnGotFocus(GotFocusEventArgs args)
 {
     GotFocus?.Invoke(this, args);
 }
コード例 #15
0
 internal void RaiseGotFocus(RoutedEventArgs args) => GotFocus?.Invoke(this, args);
コード例 #16
0
ファイル: Control.cs プロジェクト: exomia/framework
 protected virtual void OnGotFocus()
 {
     GotFocus?.Invoke(this);
 }
コード例 #17
0
 protected internal virtual void OnGotFocus(EventArgs e)
 {
     GotFocus?.Invoke(this, e);
 }
コード例 #18
0
ファイル: UITextBox.cs プロジェクト: halfmoon2014/localtest
 private void Edit_GotFocus(object sender, EventArgs e)
 {
     GotFocus?.Invoke(this, e);
 }
コード例 #19
0
 protected virtual void OnGotFocus(object sender, UIEventArgs e)
 {
     GotFocus?.Invoke(sender, e);
 }
コード例 #20
0
 private void FormOnGotFocus(object sender, EventArgs e) =>
 GotFocus?.Invoke(this, e);
コード例 #21
0
 internal void Internal_OnGotFocus()
 {
     GotFocus?.Invoke();
     GUI.OnGotFocus();
 }
コード例 #22
0
ファイル: Widget.cs プロジェクト: ronaldwu/GameLibrary
 protected virtual void OnGotFocus()
 {
     GotFocus.SafeInvoke(this, EventArgs.Empty);
 }
コード例 #23
0
ファイル: FakeTextBox.cs プロジェクト: zan00789/reko
 public void FireGotFocus()
 {
     GotFocus.Fire(this);
 }
コード例 #24
0
 public override void DidBecomeKey(NSNotification notification)
 {
     GotFocus?.Invoke(this, EventArgs.Empty);
 }
コード例 #25
0
 void Content_GotFocus(object sender, RoutedEventArgs e) => GotFocus?.Invoke(this, EventArgs.Empty);
コード例 #26
0
 protected virtual void OnGotFocus(IEventArgs e) =>
 GotFocus?.Invoke(this, e);