Skip to content

Commit

Permalink
Update the whole dialog in braille if a contained progress bar change…
Browse files Browse the repository at this point in the history
…s (issue #6862, PR #6880)
  • Loading branch information
dkager authored and jcsteh committed Jun 1, 2017
1 parent 72c82f7 commit 68081f1
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions source/braille.py
Expand Up @@ -10,6 +10,7 @@
import pkgutil
import ctypes.wintypes
import threading
import time
import wx
import louis
import winKernel
Expand Down Expand Up @@ -1726,6 +1727,20 @@ def _doCursorMove(self, region):
elif self.buffer is self.messageBuffer and keyboardHandler.keyCounter>self._keyCountForLastMessage:
self._dismissMessage()

# #6862: The value change of a progress bar change often goes together with changes of other objects in the dialog,
# e.g. the time remaining. Therefore, update the dialog when a contained progress bar changes.
def _handleProgressBarUpdate(self, obj):
oldTime = getattr(self, "_lastProgressBarUpdateTime", None)
newTime = time.time()
if oldTime and newTime - oldTime < 1:
# Fetching dialog text is expensive, so update at most once a second.
return
self._lastProgressBarUpdateTime = newTime
for obj in reversed(api.getFocusAncestors()[:-1]):
if obj.role == controlTypes.ROLE_DIALOG:
self.handleUpdate(obj)
return

def handleUpdate(self, obj):
if not self.enabled:
return
Expand All @@ -1736,6 +1751,15 @@ def handleUpdate(self, obj):
break
else:
# No region for this object.
# There are some objects that require special update behavior even if they have no region.
# This only applies when tethered to focus, because tethering to review shows only one object at a time,
# which always has a braille region associated with it.
if self.tether != self.TETHER_FOCUS:
return
# Late import to avoid circular import.
from NVDAObjects import NVDAObject
if isinstance(obj, NVDAObject) and obj.role == controlTypes.ROLE_PROGRESSBAR and obj.isInForeground:
self._handleProgressBarUpdate(obj)
return
self.mainBuffer.saveWindow()
region.update()
Expand Down

0 comments on commit 68081f1

Please sign in to comment.