1- /*
1+ /*
22Copyright (c) 2014, Lars Brubaker
33All rights reserved.
44
@@ -108,17 +108,17 @@ public void SetHoveredWidget(GuiWidget widgetToShowToolTipFor)
108108 {
109109 timeSinceMouseOver . Restart ( ) ;
110110 this . widgetThatWantsToShowToolTip = widgetToShowToolTipFor ;
111- this . lastTextShown = widgetToShowToolTipFor . ToolTipText ;
111+ this . lastTextShown = widgetToShowToolTipFor . ToolTipText ?? "" ;
112112 }
113113 else if ( toolTipWidget != null
114114 && widgetToShowToolTipFor != null
115- && lastTextShown != widgetToShowToolTipFor . ToolTipText )
115+ && lastTextShown != ( widgetToShowToolTipFor . ToolTipText ?? "" ) )
116116 {
117117 // change the text and reset the timer
118118 timeSinceMouseOver . Restart ( ) ;
119- this . lastTextShown = widgetToShowToolTipFor . ToolTipText ;
119+ this . lastTextShown = widgetToShowToolTipFor . ToolTipText ?? "" ;
120120 // and set the text of the current widget
121- changeWidgetText ? . Invoke ( toolTipWidget , widgetToShowToolTipFor . ToolTipText ) ;
121+ changeWidgetText ? . Invoke ( toolTipWidget , widgetToShowToolTipFor . ToolTipText ?? "" ) ;
122122 }
123123 }
124124
@@ -221,7 +221,12 @@ private void DoShowToolTip()
221221 RemoveToolTip ( ) ;
222222 widgetThatIsShowingToolTip = null ;
223223
224- toolTipText = widgetThatWantsToShowToolTip . ToolTipText ;
224+ toolTipText = widgetThatWantsToShowToolTip . ToolTipText ?? "" ;
225+ if ( toolTipText . Length == 0 )
226+ {
227+ widgetThatWantsToShowToolTip = null ;
228+ return ;
229+ }
225230 toolTipWidget = new FlowLayoutWidget ( )
226231 {
227232 OriginRelativeParent = new Vector2 ( ( int ) mousePosition . X , ( int ) mousePosition . Y ) ,
@@ -236,7 +241,7 @@ private void DoShowToolTip()
236241 toolTipWidget . AddChild ( widgetToShow ) ;
237242
238243 // Increase the delay to make long text stay on screen long enough to read
239- double ratioOfExpectedText = Math . Max ( 1 , widgetThatWantsToShowToolTip . ToolTipText . Length / 50.0 ) ;
244+ double ratioOfExpectedText = Math . Max ( 1 , toolTipText . Length / 50.0 ) ;
240245 CurrentAutoPopDelay = ratioOfExpectedText * AutoPopDelay ;
241246
242247 systemWindow . AddChild ( toolTipWidget ) ;
0 commit comments