Skip to content

Commit 1d83af9

Browse files
committed
Handle off-screen edit window. Fixes #105.
(Thanks to @wh1t3cAt1k )
1 parent 3ebb765 commit 1d83af9

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Source/ExcelDna.IntelliSense/ToolTipForm.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,10 @@ public void ShowToolTip(FormattedText text, string linePrefix, int left, int top
125125
if (left != _showLeft || top != _showTop || topOffset != _topOffset || listLeft != _listLeft)
126126
{
127127
// Update the start position and the current position
128-
_currentLeft = left;
129-
_currentTop = top;
130-
_showLeft = left;
131-
_showTop = top;
128+
_currentLeft = Math.Max(left, 0); // Don't move off the screen
129+
_currentTop = Math.Max(top, -topOffset);
130+
_showLeft = _currentLeft;
131+
_showTop = _currentTop;
132132
_topOffset = topOffset;
133133
_listLeft = listLeft;
134134
}
@@ -477,6 +477,9 @@ void UpdateLocation(int width, int height)
477477
_currentLeft = _listLeft.Value - width - leftPadding;
478478
}
479479
}
480+
481+
if (_currentLeft < 0)
482+
_currentLeft = 0;
480483
}
481484
SetBounds(_currentLeft, _currentTop + _topOffset, width, height);
482485
}

0 commit comments

Comments
 (0)