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); } }
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(); }
void NotifyGotFocus() { if (!hasFocus) { hasFocus = true; lastViewFocused.SetTarget(this); GotFocus?.Invoke(this, EventArgs.Empty); } }
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 } }
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); }
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); }
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); }
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 }
/// <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)); }; }
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); }; }
void OnEntryFocused(object sender, EventArgs e) { ShowPickerWindow(); GotFocus?.Invoke(this, EventArgs.Empty); }
/// <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); }
protected internal virtual void OnGotFocus(GotFocusEventArgs args) { GotFocus?.Invoke(this, args); }
internal void RaiseGotFocus(RoutedEventArgs args) => GotFocus?.Invoke(this, args);
protected virtual void OnGotFocus() { GotFocus?.Invoke(this); }
protected internal virtual void OnGotFocus(EventArgs e) { GotFocus?.Invoke(this, e); }
private void Edit_GotFocus(object sender, EventArgs e) { GotFocus?.Invoke(this, e); }
protected virtual void OnGotFocus(object sender, UIEventArgs e) { GotFocus?.Invoke(sender, e); }
private void FormOnGotFocus(object sender, EventArgs e) => GotFocus?.Invoke(this, e);
internal void Internal_OnGotFocus() { GotFocus?.Invoke(); GUI.OnGotFocus(); }
protected virtual void OnGotFocus() { GotFocus.SafeInvoke(this, EventArgs.Empty); }
public void FireGotFocus() { GotFocus.Fire(this); }
public override void DidBecomeKey(NSNotification notification) { GotFocus?.Invoke(this, EventArgs.Empty); }
void Content_GotFocus(object sender, RoutedEventArgs e) => GotFocus?.Invoke(this, EventArgs.Empty);
protected virtual void OnGotFocus(IEventArgs e) => GotFocus?.Invoke(this, e);