77available in Visual Studio and SQL Server Management Studio.
88"""
99
10- from . import UIA
10+ from . import UIA , ToolTip
1111import speech
1212import braille
1313import api
14+ import time
1415
1516
1617class IntelliSenseItem (UIA ):
@@ -53,6 +54,32 @@ class IntelliSenseLiveRegion(UIA):
5354}
5455
5556
57+ class CompletionToolTip (ToolTip ):
58+ """ A tool tip for which duplicate open events can be fired.
59+ """
60+
61+ _lastToolTipOpenedInfo = (None , None ) #: Keeps track of the last ToolTipOpened event (text, time)
62+ _preventDuplicateToolTipSeconds = 0.2 #: The duplicate tooltip events will be dropped within this time window
63+
64+ def event_UIA_toolTipOpened (self ):
65+ oldText , oldTime = self ._lastToolTipOpenedInfo
66+ newText = self .name
67+ newTime = time .time ()
68+ self .__class__ ._lastToolTipOpenedInfo = (newText , newTime )
69+ withinPossibleDupToolTipTimeWindow = (
70+ oldTime is not None
71+ and (newTime - oldTime ) < self ._preventDuplicateToolTipSeconds
72+ )
73+ if newText == oldText and withinPossibleDupToolTipTimeWindow :
74+ # Tool-tip event suspected to be a duplicate, drop the event.
75+ # - Users attempting to rapidly re-announce tool-tips may
76+ # have the announcement erroneously suppressed
77+ # - Users on slower systems (or systems under load) may still
78+ # receive duplicate announcements
79+ return
80+ super ().event_UIA_toolTipOpened ()
81+
82+
5683def findExtraOverlayClasses (obj , clsList ):
5784 if obj .UIAAutomationId in _INTELLISENSE_LIST_AUTOMATION_IDS :
5885 clsList .insert (0 , IntelliSenseList )
@@ -64,3 +91,5 @@ def findExtraOverlayClasses(obj, clsList):
6491 and isinstance (obj .previous .previous , IntelliSenseList )
6592 ):
6693 clsList .insert (0 , IntelliSenseLiveRegion )
94+ elif obj .UIAAutomationId == "completion tooltip" :
95+ clsList .insert (0 , CompletionToolTip )
0 commit comments