/// <summary> /// Update display if input has changed, or hide display if focus has been lost /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void QuickSearchPopupTimer_Tick(object sender, EventArgs e) { Point mousePosition = Point.Empty, ul = Point.Empty; Rectangle rt = Rectangle.Empty; Timer.Enabled = false; //SystemUtil.Beep(); // debug //SystemUtil.Beep(); SessionManager sm = SessionManager.Instance; Form shell = sm.ShellForm; bool shellContainsFocus = shell != null ? shell.ContainsFocus : false; bool quickSearchPopupVisible = this.Visible; bool quickSearchPopupContainsFocus = this.ContainsFocus; bool ribbonCtlContainsFocus = sm.RibbonCtl.ContainsFocus; bool gridCtlContainsFocus = sm.RibbonCtl.ContainsFocus; bool commandLineControlContainsFocus = CommandLineControl.ContainsFocus; // capture values for debugging bool listControlcontainsFocus = ListControl.ContainsFocus; bool relatedStructuresPanelContainsFocus = RelatedStructuresControl.ContainsFocus; SessionManager.AdjustMainFormControlPositionsAsNeeded(); Control focusedCtl = UIMisc.GetFocusedControl(); Form af = Form.ActiveForm; Control ac = af != null ? af.ActiveControl : null; MouseButtons mouseButtons = MouseButtons; bool activeContextMenuVisible = (ActiveContextMenu != null) ? ActiveContextMenu.Visible : false; if (focusedCtl != LastFocusedControl) { LastFocusedControl = focusedCtl; //string fch = UIMisc.GetControlParentsString(focusedCtl); //DebugLog.Message("FocusedControl: " + fch); } bool mouseInQuickSearchPopup = false; if (this.Visible) { mousePosition = System.Windows.Forms.Control.MousePosition; ul = this.PointToScreen(new Point(0, 0)); rt = new Rectangle(ul, this.Size); if (rt.Contains(mousePosition)) { mouseInQuickSearchPopup = true; } } bool hasFocus = // should we keep the popup visible (quickSearchPopupContainsFocus || commandLineControlContainsFocus || // quick search or assoc control have focus? (ConsiderShellFocus && !shellContainsFocus)); //ribbonCtlContainsFocus || // seems to get focus after scroll of grid //gridCtlContainsFocus || //activeContextMenuVisible); if (mouseInQuickSearchPopup && !hasFocus) // if mouse is in the popup but we don't have focus then give it to ourselves { // focus seems to go elsewhere sometimes when paging down in grid control this.Focus(); //UIMisc.Beep(); } bool keepVisible = mouseInQuickSearchPopup || hasFocus; bool hidePopup = quickSearchPopupVisible && !keepVisible; // should hide if currently visible but don't want to keep it visible if (hidePopup) // focus has moved away from popup { HideQuickSearchPopup(); CommandLineControl.Text = ""; // clear any text PreviousInput = ""; ActiveContextMenu = null; //Timer.Enabled = true; return; // leave timer disabled } // if (Instance.CidAllDataCommandLineContextMenu.Visible) return; // don't send if popup already visible if (CommandLineControl.ContainsFocus) { string cid = CommandLineControl.Text; if (PreviousInput != cid) { if (DateTime.Now.Subtract(LastCommandLineControlKeyDownTime).TotalSeconds > .5) { // wait for a pause in typing before processing input PreviousInput = cid; ShowQuickSearchPopup(CommandLineControl.Text, true); } //else SystemUtil.Beep(); // debug } } Timer.Enabled = true; return; }