From 36eac67060468e95d09d69fa5e7f612462bb697e Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Wed, 12 Apr 2006 16:22:32 +0000 Subject: [PATCH] SD2-709. The debugger tooltip will now be closed when moving the mouse away from a variable if no variables have been expanded in the tooltip. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.0@1293 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Services/Debugger/DebuggerGridControl.cs | 9 +++++ .../Src/Services/Debugger/DebuggerService.cs | 33 ++++++++++++++++--- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/src/Main/Base/Project/Src/Services/Debugger/DebuggerGridControl.cs b/src/Main/Base/Project/Src/Services/Debugger/DebuggerGridControl.cs index 7ad565d8fe..a008eee964 100644 --- a/src/Main/Base/Project/Src/Services/Debugger/DebuggerGridControl.cs +++ b/src/Main/Base/Project/Src/Services/Debugger/DebuggerGridControl.cs @@ -93,6 +93,15 @@ namespace ICSharpCode.Core frm.ClientSize = new Size(frm.ClientSize.Width, row.Height + 2); } + public bool IsMouseOver { + get { + if (frm != null && !frm.IsDisposed) { + return frm.ClientRectangle.Contains(frm.PointToClient(Control.MousePosition)); + } + return false; + } + } + void OnTextAreaClick(object sender, EventArgs e) { ((ICSharpCode.TextEditor.TextArea)sender).KeyDown -= OnTextAreaClick; diff --git a/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs b/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs index 6bfe854480..20e4b33553 100644 --- a/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs +++ b/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs @@ -242,6 +242,7 @@ namespace ICSharpCode.Core textArea.IconBarMargin.MouseDown += IconBarMouseDown; textArea.ToolTipRequest += TextAreaToolTipRequest; + textArea.MouseLeave += TextAreaMouseLeave; } } @@ -252,6 +253,7 @@ namespace ICSharpCode.Core textArea.IconBarMargin.MouseDown -= IconBarMouseDown; textArea.ToolTipRequest -= TextAreaToolTipRequest; + textArea.MouseLeave -= TextAreaMouseLeave; } } @@ -286,6 +288,7 @@ namespace ICSharpCode.Core /// static void TextAreaToolTipRequest(object sender, ToolTipRequestEventArgs e) { + DebuggerGridControl toolTipControl = null; try { TextArea textArea = (TextArea)sender; if (e.ToolTipShown) return; @@ -314,7 +317,6 @@ namespace ICSharpCode.Core ResolveResult result = ParserService.Resolve(expressionResult, logicPos.Y + 1, logicPos.X + 1, textArea.MotherTextEditorControl.FileName, textContent); bool debuggerCanShowValue; string toolTipText = GetText(result, expression, out debuggerCanShowValue); - DebuggerGridControl toolTipControl = null; if (toolTipText != null) { if (Control.ModifierKeys == Keys.Control) { toolTipText = "expr: " + expressionResult.ToString() + "\n" + toolTipText; @@ -326,10 +328,7 @@ namespace ICSharpCode.Core if (toolTipText != null) { e.ShowToolTip(toolTipText); } - if (oldToolTipControl != null) { - Form frm = oldToolTipControl.FindForm(); - if (frm != null) frm.Close(); - } + CloseOldToolTip(); if (toolTipControl != null) { toolTipControl.ShowForm(textArea, logicPos); } @@ -338,9 +337,33 @@ namespace ICSharpCode.Core } } catch (Exception ex) { ICSharpCode.Core.MessageService.ShowError(ex); + } finally { + if (toolTipControl == null && CanCloseOldToolTip) + CloseOldToolTip(); + } + } + + static bool CanCloseOldToolTip { + get { + return oldToolTipControl != null && oldToolTipControl.AllowClose; + } + } + + static void CloseOldToolTip() + { + if (oldToolTipControl != null) { + Form frm = oldToolTipControl.FindForm(); + if (frm != null) frm.Close(); + oldToolTipControl = null; } } + static void TextAreaMouseLeave(object source, EventArgs e) + { + if (CanCloseOldToolTip && !oldToolTipControl.IsMouseOver) + CloseOldToolTip(); + } + static string GetText(ResolveResult result, string expression, out bool debuggerCanShowValue) { debuggerCanShowValue = false;