private void OnFocusExit(object sender, FocusChangedArgs args) { var focusDetails = GetFocusDetails(_pointer); if (focusDetails != null) { var focusPoint = focusDetails.Value.Point; Context.EndTargeting(GetMWUnityUser(), focusPoint); TargetExited?.Invoke(this, new TargetChangedEventArgs(focusPoint)); } _pointer = null; CurrentFocusedPoint = Vector3.zero; }
private void OnFocusEnter(object sender, FocusChangedArgs args) { _pointer = args.Pointer; var focusDetails = GetFocusDetails(_pointer); if (focusDetails != null) { var focusPoint = focusDetails.Value.Point; Context.StartTargeting(GetMWUnityUser(), focusPoint); TargetEntered?.Invoke(this, new TargetChangedEventArgs(focusPoint)); CurrentFocusedPoint = focusPoint; } }
public override void OnContainsFocusChanged(FocusChangedArgs e) { if (!e.Focused) { bool reclaimFocus = false; if (holdingOpenForChild) { holdingOpenForChild = false; reclaimFocus = true; } UiThread.RunOnIdle(() => { // Fired any time focus changes. Traditionally we closed the menu if we weren't focused. // To accommodate children (or external widgets) having focus we also query for and consider special cases bool specialChildHasFocus = IgnoredWidgets.Any(w => w.ContainsFocus || w.Focused || w.KeepMenuOpen); bool descendantIsHoldingOpen = this.Descendants <GuiWidget>().Any(w => w is IIgnoredPopupChild ignoredPopupChild && ignoredPopupChild.KeepMenuOpen); bool keepMeOpen = false; if (layoutEngine.Anchor is IMenuCreator menuCreator) { keepMeOpen = menuCreator.AlwaysKeepOpen; } // If the focused changed and we've lost focus and no special cases permit, close the menu if (!this.ContainsFocus && !specialChildHasFocus && !descendantIsHoldingOpen && !holdingOpenForChild && !keepMeOpen && !DebugKeepOpen) { this.CloseMenu(); } else if (reclaimFocus && !descendantIsHoldingOpen) { this.Focus(); } holdingOpenForChild = descendantIsHoldingOpen; }); } base.OnContainsFocusChanged(e); }