Browse Source

Fixed the mouse cursor staying hidden after typing when the text area loses focus without the mouse being moved (e.g. when the user types some code and then opens a modal dialog box by using keyboard shortcuts only).

Fixed the mouse cursor staying hidden behind the CodeCompletionWindow or InsightWindow until moved out.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.1@2499 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Christian Hornung 19 years ago
parent
commit
444f6b6341
  1. 1
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/CodeCompletionWindow.cs
  2. 28
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/CompletionWindow/AbstractCompletionWindow.cs
  3. 1
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/CompletionWindow/CodeCompletionWindow.cs
  4. 24
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextArea.cs
  5. 23
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaMouseHandler.cs

1
src/AddIns/DisplayBindings/XmlEditor/Project/Src/CodeCompletionWindow.cs

@ -79,6 +79,7 @@ namespace ICSharpCode.XmlEditor @@ -79,6 +79,7 @@ namespace ICSharpCode.XmlEditor
declarationViewWindow = new DeclarationViewWindow(parentForm);
SetDeclarationViewLocation();
declarationViewWindow.MouseMove += ControlMouseMove;
declarationViewWindow.ShowDeclarationViewWindow();
control.Focus();
CodeCompletionListViewSelectedItemChanged(this, EventArgs.Empty);

28
src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/CompletionWindow/AbstractCompletionWindow.cs

@ -125,6 +125,10 @@ namespace ICSharpCode.TextEditor.Gui.CompletionWindow @@ -125,6 +125,10 @@ namespace ICSharpCode.TextEditor.Gui.CompletionWindow
control.ActiveTextAreaControl.Caret.PositionChanged += new EventHandler(CaretOffsetChanged);
control.ActiveTextAreaControl.TextArea.LostFocus += new EventHandler(this.TextEditorLostFocus);
control.Resize += new EventHandler(ParentFormLocationChanged);
foreach (Control c in Controls) {
c.MouseMove += ControlMouseMove;
}
}
void ParentFormLocationChanged(object sender, EventArgs e)
@ -168,6 +172,10 @@ namespace ICSharpCode.TextEditor.Gui.CompletionWindow @@ -168,6 +172,10 @@ namespace ICSharpCode.TextEditor.Gui.CompletionWindow
// take out the inserted methods
parentForm.LocationChanged -= new EventHandler(ParentFormLocationChanged);
foreach (Control c in Controls) {
c.MouseMove -= ControlMouseMove;
}
if (control.ActiveTextAreaControl.VScrollBar != null) {
control.ActiveTextAreaControl.VScrollBar.ValueChanged -= new EventHandler(ParentFormLocationChanged);
}
@ -181,5 +189,25 @@ namespace ICSharpCode.TextEditor.Gui.CompletionWindow @@ -181,5 +189,25 @@ namespace ICSharpCode.TextEditor.Gui.CompletionWindow
control.Resize -= new EventHandler(ParentFormLocationChanged);
Dispose();
}
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
ControlMouseMove(this, e);
}
/// <summary>
/// Invoked when the mouse moves over this form or any child control.
/// Shows the mouse cursor on the text area if it has been hidden.
/// </summary>
/// <remarks>
/// Derived classes should attach this handler to the MouseMove event
/// of all created controls which are not added to the Controls
/// collection.
/// </remarks>
protected void ControlMouseMove(object sender, MouseEventArgs e)
{
control.ActiveTextAreaControl.TextArea.ShowHiddenCursor(false);
}
}
}

1
src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/CompletionWindow/CodeCompletionWindow.cs

@ -79,6 +79,7 @@ namespace ICSharpCode.TextEditor.Gui.CompletionWindow @@ -79,6 +79,7 @@ namespace ICSharpCode.TextEditor.Gui.CompletionWindow
}
SetDeclarationViewLocation();
declarationViewWindow.ShowDeclarationViewWindow();
declarationViewWindow.MouseMove += ControlMouseMove;
control.Focus();
CodeCompletionListViewSelectedItemChanged(this, EventArgs.Empty);

24
src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextArea.cs

@ -29,12 +29,12 @@ namespace ICSharpCode.TextEditor @@ -29,12 +29,12 @@ namespace ICSharpCode.TextEditor
[ToolboxItem(false)]
public class TextArea : Control
{
internal bool HiddenMouseCursor = false;
bool hiddenMouseCursor = false;
/// <summary>
/// The position where the mouse cursor was when it was hidden. Sometimes the text editor gets MouseMove
/// events when typing text even if the mouse is not moved.
/// </summary>
internal Point MouseCursorHidePosition;
Point mouseCursorHidePosition;
Point virtualTop = new Point(0, 0);
TextAreaControl motherTextAreaControl;
@ -315,6 +315,20 @@ namespace ICSharpCode.TextEditor @@ -315,6 +315,20 @@ namespace ICSharpCode.TextEditor
}
}
/// <summary>
/// Shows the mouse cursor if it has been hidden.
/// </summary>
/// <param name="forceShow"><c>true</c> to always show the cursor or <c>false</c> to show it only if it has been moved since it was hidden.</param>
internal void ShowHiddenCursor(bool forceShow)
{
if (hiddenMouseCursor) {
if (mouseCursorHidePosition != Cursor.Position || forceShow) {
Cursor.Show();
hiddenMouseCursor = false;
}
}
}
// static because the mouse can only be in one text area and we don't want to have
// tooltips of text areas from inactive tabs floating around.
@ -576,10 +590,10 @@ namespace ICSharpCode.TextEditor @@ -576,10 +590,10 @@ namespace ICSharpCode.TextEditor
return;
}
if (!HiddenMouseCursor && TextEditorProperties.HideMouseCursor) {
if (!hiddenMouseCursor && TextEditorProperties.HideMouseCursor) {
if (this.ClientRectangle.Contains(PointToClient(Cursor.Position))) {
MouseCursorHidePosition = Cursor.Position;
HiddenMouseCursor = true;
mouseCursorHidePosition = Cursor.Position;
hiddenMouseCursor = true;
Cursor.Hide();
}
}

23
src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaMouseHandler.cs

@ -91,23 +91,26 @@ namespace ICSharpCode.TextEditor @@ -91,23 +91,26 @@ namespace ICSharpCode.TextEditor
}
}
void ShowHiddenCursor(bool forceShow)
void ShowHiddenCursorIfMovedOrLeft()
{
if (textArea.HiddenMouseCursor) {
if (textArea.MouseCursorHidePosition != Cursor.Position) {
Cursor.Show();
textArea.HiddenMouseCursor = false;
}
}
textArea.ShowHiddenCursor(!textArea.Focused ||
!textArea.ClientRectangle.Contains(textArea.PointToClient(Cursor.Position)));
}
void TextAreaLostFocus(object sender, EventArgs e)
{
ShowHiddenCursor(true);
// The call to ShowHiddenCursorIfMovedOrLeft is delayed
// until pending messages have been processed
// so that it can properly detect whether the TextArea
// has really lost focus.
// For example, the CodeCompletionWindow gets focus when it is shown,
// but immediately gives back focus to the TextArea.
textArea.BeginInvoke(new MethodInvoker(ShowHiddenCursorIfMovedOrLeft));
}
void OnMouseLeave(object sender, EventArgs e)
{
ShowHiddenCursor(true);
ShowHiddenCursorIfMovedOrLeft();
gotmousedown = false;
mousedownpos = nilPoint;
}
@ -157,7 +160,7 @@ namespace ICSharpCode.TextEditor @@ -157,7 +160,7 @@ namespace ICSharpCode.TextEditor
break;
}
ShowHiddenCursor(false);
textArea.ShowHiddenCursor(false);
if (dodragdrop) {
dodragdrop = false;
return;

Loading…
Cancel
Save