Skip to content

Commit 3eb7e22

Browse files
authored
Merge af3dea3 into f0e82c7
2 parents f0e82c7 + af3dea3 commit 3eb7e22

1 file changed

Lines changed: 30 additions & 1 deletion

File tree

source/NVDAObjects/UIA/VisualStudio.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
available in Visual Studio and SQL Server Management Studio.
88
"""
99

10-
from . import UIA
10+
from . import UIA, ToolTip
1111
import speech
1212
import braille
1313
import api
14+
import time
1415

1516

1617
class 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+
5683
def 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

Comments
 (0)