Skip to content

Commit

Permalink
NVDAObjects/UIA: forcefully raise value change event for combo boxes …
Browse files Browse the repository at this point in the history
…that does expose value pattern yet does not raise the said event. re #6337 (#7132)

Some combo boxes do expose value pattern but do not raise value change event. To get around this, selection on its children (items) will be tracked (same trick as combo boxes with no value pattern).

* NVDAObjects/UIA: catch AttributeError seen in some lists. re #6337.

Caught by Jamie Teh (NV Access): when searching for items in store, the media type list is sometimes shown, and this may not have the required pattern at all. If this happens, Attribute Error is raised. When handling this, catch this error first, otherwise AttributeError will continue to be raised.
  • Loading branch information
josephsl authored and michaelDCurran committed Jun 23, 2017
1 parent 77cdcee commit dd684d1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions source/NVDAObjects/UIA/__init__.py
Expand Up @@ -2,7 +2,7 @@
#A part of NonVisual Desktop Access (NVDA)
#This file is covered by the GNU General Public License.
#See the file COPYING for more details.
#Copyright (C) 2009-2016 NV Access Limited, Joseph Lee, Mohammad Suliman
#Copyright (C) 2009-2017 NV Access Limited, Joseph Lee, Mohammad Suliman

from ctypes import byref
from ctypes.wintypes import POINT, RECT
Expand Down Expand Up @@ -1393,7 +1393,7 @@ def _get_UIASelectionPattern(self):
def _get_value(self):
try:
return self.UIASelectionPattern.GetCurrentSelection().GetElement(0).CurrentName
except COMError:
except (COMError, AttributeError):
return None

class ListItem(UIA):
Expand All @@ -1402,8 +1402,9 @@ def event_stateChange(self):
if not self.hasFocus:
parent = self.parent
focus=api.getFocusObject()
if parent and isinstance(parent, ComboBoxWithoutValuePattern) and parent==focus:
# This is an item in a combo box without the Value pattern.
if parent and parent==focus and (isinstance(parent, ComboBoxWithoutValuePattern)
or (parent._getUIACacheablePropertyValue(UIAHandler.UIA_IsValuePatternAvailablePropertyId) and parent.windowClassName.startswith("Windows.UI.Core"))):
# #6337: This is an item in a combo box without the Value pattern or does not raise value change event.
# This item has been selected, so notify the combo box that its value has changed.
focus.event_valueChange()
super(ListItem, self).event_stateChange()
Expand Down

0 comments on commit dd684d1

Please sign in to comment.