private void SetTooltip(ErrorGlyphTag newTag, ITrackingSpan trackingSpan) { if (newTag != null) { if ((_currentTag == null) || (newTag.Description != _currentTag.Description)) { _toolTipProvider.ShowToolTip(trackingSpan, newTag.Description); _currentTag = newTag; } } else if (_currentTag != null) { _toolTipProvider.ClearToolTip(); _currentTag = null; } }
public override void PreprocessMouseMove(MouseEventArgs e) { // Look for regex lines to show the tooltip/hand cursor foreach (ITextViewLine line in this.view.TextViewLines) { RegexLineData regexLineData = RegexLineData.CreateFromTextViewLine(this.view, line); // Check if the regex line contains a new Regex statement if (IsValid(regexLineData)) { // Get the pattern parameter SnapshotSpan?expression = regexLineData.Expression; if (expression.HasValue) { // Get the marker geometry of the pattern parameter Geometry expressionGeometry = view.TextViewLines.GetMarkerGeometry(expression.Value); if (expressionGeometry != null && expressionGeometry.Bounds.Contains(GetPointRelativeToView(e))) { e.Handled = true; if (!IsToolTipShown) { IsToolTipShown = true; IToolTipProvider toolTipProvider = this.toolTipProviderFactory.GetToolTipProvider(this.view); // Show the tooltip toolTipProvider.ShowToolTip(expression.Value.Snapshot.CreateTrackingSpan( expression.Value.Span, SpanTrackingMode.EdgeExclusive), "Ctrl+Click to open the regex editor", PopupStyles.DismissOnMouseLeaveText); } // If the ctrl key is pressed change the cursor to hand if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) { e.MouseDevice.OverrideCursor = Cursors.Hand; } return; } } } } IsToolTipShown = false; e.MouseDevice.OverrideCursor = null; }
private void DisplayTooltip(SnapshotSpan span) { _toolTipProvider.ClearToolTip(); _isTooltipShown = true; // Note, keep a local copy of ActiveTagData.Current. // In case ActiveTagData.Current changes by other thread or by async re-entrancy. ActiveTagData activeData = ActiveTagData.Current; if (activeData == null) { Debug.WriteLine($"{nameof(ActiveTagData.Current)} is empty, this is probably a code bug."); return; } activeData.TooltipControl.Width = _view.ViewportWidth; _toolTipProvider.ShowToolTip( span.Snapshot.CreateTrackingSpan(span, SpanTrackingMode.EdgeExclusive), activeData.TooltipControl, PopupStyles.PositionClosest); }