UIA/keyboard shortcut: do not append two spaces if access key is there but accelerator key isn't #6790
In some cases (such as in Outlook 2016 ribbon), controls have access keys but not accelerator keys. If so, two spaces are appended. This should tno be done in order to not waste string real estte.
Note: the PR for it will be part of the PR for #6779. Thanks.
The text was updated successfully, but these errors were encountered:
… longer adding two spaces blindly if access key is there but accelerator isnt. re nvaccess#6779, nvaccess#6790. For 6779: there's no check for the case where access key may return NULL (None), thus take care of this by forcefully setting access key to an empty string. For 6790: don't add two spaces blindly if access key is there but accelerator isn't - keyboard shortcut is queried not only in Visual Studio, but also in other programs such as Outlook and many others. Overall code: made it more Pythonic (for instance, using str.join instead of string concatenation).
…ey and accelerator are present, return longest string otherwise. re nvaccess#6790. A Python trick: when checking for logical and for two strings, it'll return a string (an empty string if one or both are truly empty). If logical and says 'false', then just return the longest string as the keyboard shortcut, otherwise insert two spaces.
…ute error early, append to shortcuts list early. re nvaccess#6779, nvaccess#6790. Reviewed by Jamie Teh (NV Access): we still want to catch NULL, so catch AttributeError exception early. Also, append access key and accelerator as soon as possible 9if they are even defined). Lastly, simplified the return statement to check for presence of access key and/or accelerator in the shortcuts list (len is at least 1), and return an an empty string if no info found. These changes shuld hopefully improve readability.