File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -274,11 +274,15 @@ class Switch(Ia2Web):
274274 # role="switch" gets mapped to IA2_ROLE_TOGGLE_BUTTON, but it uses the
275275 # checked state instead of pressed. The simplest way to deal with this
276276 # identity crisis is to map it to a check box.
277- role = controlTypes .Role .CHECKBOX
277+ role = controlTypes .Role .SWITCH
278278
279279 def _get_states (self ):
280280 states = super ().states
281281 states .discard (controlTypes .State .PRESSED )
282+ states .discard (controlTypes .State .CHECKABLE )
283+ if controlTypes .State .CHECKED in states :
284+ states .discard (controlTypes .State .CHECKED )
285+ states .add (controlTypes .State .ON )
282286 return states
283287
284288
Original file line number Diff line number Diff line change 208208 controlTypes .Role .SUGGESTION : _ ("sggstn" ),
209209 # Translators: Displayed in braille when an object is a definition.
210210 controlTypes .Role .DEFINITION : _ ("definition" ),
211+ # Translators: Displayed in braille when an object is a switch control
212+ controlTypes .Role .SWITCH : _ ("swtch" ),
211213}
212214
213215positiveStateLabels = {
251253 controlTypes .State .HASFORMULA : _ ("frml" ),
252254 # Translators: Displayed in braille when there is a comment for a spreadsheet cell or piece of text in a document.
253255 controlTypes .State .HASCOMMENT : _ ("cmnt" ),
256+ # Translators: Displayed in braille when a control is switched on
257+ controlTypes .State .ON : u"⣏⣿⣹" ,
254258}
255259negativeStateLabels = {
256260 # Translators: Displayed in braille when an object is not selected.
259263 controlTypes .State .PRESSED : u"⢎⣀⡱" ,
260264 # Displayed in braille when an object (e.g. a check box) is not checked.
261265 controlTypes .State .CHECKED : u"⣏⣀⣹" ,
266+ # Displayed in braille when an object (e.g. a switch control) is switched off.
267+ controlTypes .State .ON : u"⣏⣀⣹" ,
262268}
263269
264270landmarkLabels = {
Original file line number Diff line number Diff line change @@ -128,6 +128,8 @@ def _processNegativeStates(
128128 speakNegatives .add (State .CHECKED )
129129 if role == Role .TOGGLEBUTTON and State .HALF_PRESSED not in states :
130130 speakNegatives .add (State .PRESSED )
131+ if role is Role .SWITCH and State .ON not in states :
132+ speakNegatives .add (State .ON )
131133 if reason == OutputReason .CHANGE :
132134 # We want to speak this state only if it is changing to negative.
133135 speakNegatives .add (State .DROPTARGET )
Original file line number Diff line number Diff line change @@ -201,6 +201,7 @@ def _displayStringLabels(self):
201201 COMMENT = 155
202202 SUGGESTION = 156
203203 DEFINITION = 157
204+ SWITCH = 158
204205
205206
206207_roleLabels : Dict [Role , str ] = {
@@ -528,6 +529,9 @@ def _displayStringLabels(self):
528529 Role .SUGGESTION : _ ("suggestion" ),
529530 # Translators: Identifies a definition.
530531 Role .DEFINITION : _ ("definition" ),
532+ # Translators: The word role for a switch control
533+ # I.e. a control that can be switched on or off.
534+ Role .SWITCH : _ ("switch" ),
531535}
532536
533537
Original file line number Diff line number Diff line change @@ -97,6 +97,7 @@ def negativeDisplayString(self) -> str:
9797 # when combined with role of 'progress bar', role is mutated to 'busy indicator'
9898 INDETERMINATE = setBit (44 )
9999 HALF_PRESSED = setBit (45 )
100+ ON = setBit (46 )
100101
101102
102103STATES_SORTED = frozenset ([State .SORTED , State .SORTED_ASCENDING , State .SORTED_DESCENDING ])
@@ -188,6 +189,9 @@ def negativeDisplayString(self) -> str:
188189 State .UNLOCKED : _ ("unlocked" ),
189190 # Translators: a state that denotes the existence of a note.
190191 State .HASNOTE : _ ("has note" ),
192+ # Translators: a state that denotes a control is currently on
193+ # E.g. a switch control.
194+ State .ON : _ ("on" ),
191195}
192196
193197
@@ -201,4 +205,6 @@ def negativeDisplayString(self) -> str:
201205 # Translators: This is presented when drag and drop is finished.
202206 # This is only reported for objects which support accessible drag and drop.
203207 State .DROPTARGET : _ ("done dragging" ),
208+ # Translators: This is presented when a switch control is off.
209+ State .ON : _ ("off" ),
204210}
Original file line number Diff line number Diff line change @@ -119,6 +119,7 @@ def getPresentationCategory(
119119 controlTypes .Role .BUTTON ,
120120 controlTypes .Role .RADIOBUTTON ,
121121 controlTypes .Role .CHECKBOX ,
122+ controlTypes .Role .SWITCH ,
122123 controlTypes .Role .GRAPHIC ,
123124 controlTypes .Role .CHART ,
124125 controlTypes .Role .MENUITEM ,
Original file line number Diff line number Diff line change @@ -155,10 +155,14 @@ def _normalizeControlField(self, attrs): # noqa: C901
155155 role = controlTypes .Role .REGION
156156 elif xmlRoles [0 ] == "switch" :
157157 # role="switch" gets mapped to IA2_ROLE_TOGGLE_BUTTON, but it uses the
158- # checked state instead of pressed. The simplest way to deal with this
159- # identity crisis is to map it to a check box .
160- role = controlTypes .Role .CHECKBOX
158+ # checked state instead of pressed.
159+ # We want to map this to our own Switch role and On state .
160+ role = controlTypes .Role .SWITCH
161161 states .discard (controlTypes .State .PRESSED )
162+ states .discard (controlTypes .State .CHECKABLE )
163+ if controlTypes .State .CHECKED in states :
164+ states .discard (controlTypes .State .CHECKED )
165+ states .add (controlTypes .State .ON )
162166 attrs ['role' ]= role
163167 attrs ['states' ]= states
164168 if level != "" and level is not None :
You can’t perform that action at this time.
0 commit comments