@@ -1725,8 +1725,7 @@ def getPropertiesSpeech( # noqa: C901
17251725 textList .append (description )
17261726 # sometimes keyboardShortcut key is present but value is None
17271727 keyboardShortcut : Optional [str ] = propertyValues .get ('keyboardShortcut' )
1728- if keyboardShortcut :
1729- textList .append (keyboardShortcut )
1728+ textList .extend (getKeyboardShortcutSpeech (keyboardShortcut ))
17301729 if includeTableCellCoords and cellCoordsText :
17311730 textList .append (cellCoordsText )
17321731 if cellCoordsText or rowNumber or columnNumber :
@@ -1861,6 +1860,58 @@ def getPropertiesSpeech( # noqa: C901
18611860 return textList
18621861
18631862
1863+ def getKeyboardShortcutSpeech (keyboardShortcut : Optional [str ]) -> SpeechSequence :
1864+ log .info (f'Calling getKeyboardShortcutSequence with keyboardShortcut={ keyboardShortcut } ' )
1865+ SHORTCUT_KEY_LIST_SEPARATOR = ' '
1866+ seq = []
1867+ if not keyboardShortcut :
1868+ return seq
1869+ locale = getCurrentLanguage ()
1870+ for shortcut in keyboardShortcut .split (SHORTCUT_KEY_LIST_SEPARATOR ):
1871+ if len (seq ) > 0 :
1872+ seq .append (SHORTCUT_KEY_LIST_SEPARATOR )
1873+ keyList , separator = splitShortcut (shortcut )
1874+ log .info (f'keyList={ keyList } , separator={ separator } ' )
1875+ seqShortcut = []
1876+ for key in keyList :
1877+ if len (seqShortcut ) > 0 :
1878+ seqShortcut .append (separator )
1879+ if len (key ) > 1 :
1880+ seqShortcut .append (key )
1881+ continue
1882+ keySymbol = characterProcessing .processSpeechSymbol (locale , key )
1883+ if keySymbol != key :
1884+ seqShortcut .append (keySymbol )
1885+ continue
1886+ seqShortcut .append (CharacterModeCommand (True ))
1887+ seqShortcut .append (key )
1888+ seqShortcut .append (CharacterModeCommand (False ))
1889+ seq .extend (seqShortcut )
1890+ seqOut = []
1891+ for item in seq :
1892+ if len (seqOut ) > 0 and isinstance (seqOut [- 1 ], str ) and isinstance (item , str ):
1893+ seqOut [- 1 ] = seqOut [- 1 ] + SHORTCUT_KEY_LIST_SEPARATOR + item
1894+ else :
1895+ seqOut .append (item )
1896+ return seqOut
1897+
1898+
1899+ def splitShortcut (shortcut ):
1900+ if ', ' in shortcut :
1901+ separator = ', '
1902+ elif ' + ' in shortcut :
1903+ separator = ' + '
1904+ elif '+' in shortcut :
1905+ separator = '+'
1906+ else :
1907+ separator = None
1908+ if separator :
1909+ keyList = shortcut .split (separator )
1910+ else :
1911+ keyList = [shortcut ]
1912+ return keyList , separator
1913+
1914+
18641915def _shouldSpeakContentFirst (
18651916 reason : OutputReason ,
18661917 role : int ,
0 commit comments