Skip to content

Commit

Permalink
Handle off-screen edit window. Fixes #105.
Browse files Browse the repository at this point in the history
(Thanks to @wh1t3cAt1k )
  • Loading branch information
govert committed Mar 22, 2021
1 parent 3ebb765 commit 1d83af9
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Source/ExcelDna.IntelliSense/ToolTipForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ public void ShowToolTip(FormattedText text, string linePrefix, int left, int top
if (left != _showLeft || top != _showTop || topOffset != _topOffset || listLeft != _listLeft)
{
// Update the start position and the current position
_currentLeft = left;
_currentTop = top;
_showLeft = left;
_showTop = top;
_currentLeft = Math.Max(left, 0); // Don't move off the screen
_currentTop = Math.Max(top, -topOffset);
_showLeft = _currentLeft;
_showTop = _currentTop;
_topOffset = topOffset;
_listLeft = listLeft;
}
Expand Down Expand Up @@ -477,6 +477,9 @@ void UpdateLocation(int width, int height)
_currentLeft = _listLeft.Value - width - leftPadding;
}
}

if (_currentLeft < 0)
_currentLeft = 0;
}
SetBounds(_currentLeft, _currentTop + _topOffset, width, height);
}
Expand Down

0 comments on commit 1d83af9

Please sign in to comment.