From: James Teh Date: Mon, 10 Sep 2012 06:44:46 +0000 (+1000) Subject: NVDAObject: Add isFocusable and hasFocus properties. X-Git-Tag: jpdev130418~605^2~8 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=ce14b83b37aab20be750b41785325830e334cb42;p=nvdajp%2Fnvdajp.git NVDAObject: Add isFocusable and hasFocus properties. The base implementation just checks states, but subclasses may wish to override these rather than using states, as fetching all states can be expensive. --- diff --git a/source/NVDAObjects/__init__.py b/source/NVDAObjects/__init__.py index 8b98d30d0..c5b3fae9a 100644 --- a/source/NVDAObjects/__init__.py +++ b/source/NVDAObjects/__init__.py @@ -659,6 +659,18 @@ class NVDAObject(baseObject.ScriptableObject): """ return None + def _get_isFocusable(self): + """Whether this object is focusable. + @rtype: bool + """ + return controlTypes.STATE_FOCUSABLE in self.states + + def _get_hasFocus(self): + """Whether this object has focus. + @rtype: bool + """ + return controlTypes.STATE_FOCUSED in self.states + def setFocus(self): """ Tries to force this object to take the focus. @@ -910,6 +922,16 @@ This code is executed if a gain focus event is received by this object. ret = "exception: %s" % e info.append("states: %s" % ret) try: + ret = repr(self.isFocusable) + except Exception as e: + ret = "exception: %s" % e + info.append("isFocusable: %s" % ret) + try: + ret = repr(self.hasFocus) + except Exception as e: + ret = "exception: %s" % e + info.append("hasFocus: %s" % ret) + try: ret = repr(self) except Exception as e: ret = "exception: %s" % e