def locusOfFocusChanged(self, event, oldLocusOfFocus, newLocusOfFocus): """Called when the visual object with focus changes. Arguments: - event: if not None, the Event that caused the change - oldLocusOfFocus: Accessible that is the old locus of focus - newLocusOfFocus: Accessible that is the new locus of focus """ brailleGen = self.brailleGenerator speechGen = self.speechGenerator debug.printObjectEvent(self.debugLevel, event, event.source.toString()) # Here we handle the case when focus is in the "Work online/offline" # button near the status bar that has an image without a description. # We speak and braille "Online/Offline button" here, until the # developer of the application adds a description to the images # associated with the button, which shows the online or offline # work mode. # rolesList = [rolenames.ROLE_PUSH_BUTTON, rolenames.ROLE_FILLER, rolenames.ROLE_FILLER, rolenames.ROLE_FRAME] # We are checking if the button with the focus is the button to # turn on/off the work mode in liferea. This push button is # hierarchically located in the main window of the application # (frame), inside a filler and inside another filler. # if self.isDesiredFocusedItem(event.source, rolesList): # If we are focusing this button we construct a utterance and # a braille region to speak/braille "online/offline button". # Here we declare utterances and add the localized string # "online/offline". # utterances = [] utterances.append(_("Work online / offline")) # Here we extend the utterances with the speech generator for # the object with focus (the push button). # utterances.extend(speechGen.getSpeech(event.source,False)) # Finally we speak/braille the utterances/regions. # speech.speakUtterances(utterances) regions = brailleGen.getBrailleRegions(event.source) regions[0].insert(0, braille.Region(utterances[0] + " ")) braille.displayRegions(regions) return # Here we handle the case when the focus is in the headlines table. # See comment #3 of bug #350233. # http://bugzilla.gnome.org/show_bug.cgi?id=350233 # if orca_state.locusOfFocus.role == rolenames.ROLE_TABLE_COLUMN_HEADER: table = event.source.parent cells = self.findByRole(table, rolenames.ROLE_TABLE_CELL) eventsynthesizer.clickObject(cells[1], 1) default.Script.locusOfFocusChanged(self, event, oldLocusOfFocus, newLocusOfFocus)
def locusOfFocusChanged(self, event, oldLocusOfFocus, newLocusOfFocus): """Called when the visual object with focus changes. Arguments: - event: if not None, the Event that caused the change - oldLocusOfFocus: Accessible that is the old locus of focus - newLocusOfFocus: Accessible that is the new locus of focus """ brailleGen = self.brailleGenerator speechGen = self.speechGenerator details = debug.getAccessibleDetails(self.debugLevel, event.source) debug.printObjectEvent(self.debugLevel, event, details) # [[[TODO - JD: what follows here should be replaced with methods # in this script's speech and braille generators. That will require # making each generator, moving this script into a new directory, # etc.]]] # # Here we handle the case when focus is in the "Work online/offline" # button near the status bar that has an image without a description. # We speak and braille "Online/Offline button" here, until the # developer of the application adds a description to the images # associated with the button, which shows the online or offline # work mode. # rolesList = [ pyatspi.ROLE_PUSH_BUTTON, pyatspi.ROLE_FILLER, pyatspi.ROLE_FILLER, pyatspi.ROLE_FRAME ] # We are checking if the button with the focus is the button to # turn on/off the work mode in liferea. This push button is # hierarchically located in the main window of the application # (frame), inside a filler and inside another filler. # if self.utilities.hasMatchingHierarchy(event.source, rolesList): # If we are focusing this button we construct a utterance and # a braille region to speak/braille "online/offline button". # Here we declare utterances and add the localized string # "online/offline". # utterances = [] utterances.append(_("Work online / offline")) # Here we extend the utterances with the speech generator for # the object with focus (the push button). # utterances.extend(speechGen.generateSpeech(event.source)) # Finally we speak/braille the utterances/regions. # speech.speak(utterances) regions = brailleGen.generateBraille(event.source) regions[0].insert(0, self.getNewBrailleRegion(utterances[0] + " ")) self.displayBrailleRegions(regions) return # Here we handle the case when the focus is in the headlines table. # See comment #3 of bug #350233. # http://bugzilla.gnome.org/show_bug.cgi?id=350233 # if orca_state.locusOfFocus.getRole() == \ pyatspi.ROLE_TABLE_COLUMN_HEADER: table = event.source.parent hasRole = lambda x: x and x.getRole() == pyatspi.ROLE_TABLE_CELL cells = pyatspi.findAllDescendants(event.source, hasRole) eventsynthesizer.clickObject(cells[1], 1) default.Script.locusOfFocusChanged(self, event, oldLocusOfFocus, newLocusOfFocus)
def locusOfFocusChanged(self, event, oldLocusOfFocus, newLocusOfFocus): """Called when the visual object with focus changes. Arguments: - event: if not None, the Event that caused the change - oldLocusOfFocus: Accessible that is the old locus of focus - newLocusOfFocus: Accessible that is the new locus of focus """ brailleGen = self.brailleGenerator speechGen = self.speechGenerator details = debug.getAccessibleDetails(self.debugLevel, event.source) debug.printObjectEvent(self.debugLevel, event, details) # [[[TODO - JD: what follows here should be replaced with methods # in this script's speech and braille generators. That will require # making each generator, moving this script into a new directory, # etc.]]] # # Here we handle the case when focus is in the "Work online/offline" # button near the status bar that has an image without a description. # We speak and braille "Online/Offline button" here, until the # developer of the application adds a description to the images # associated with the button, which shows the online or offline # work mode. # rolesList = [pyatspi.ROLE_PUSH_BUTTON, pyatspi.ROLE_FILLER, pyatspi.ROLE_FILLER, pyatspi.ROLE_FRAME] # We are checking if the button with the focus is the button to # turn on/off the work mode in liferea. This push button is # hierarchically located in the main window of the application # (frame), inside a filler and inside another filler. # if self.utilities.hasMatchingHierarchy(event.source, rolesList): # If we are focusing this button we construct a utterance and # a braille region to speak/braille "online/offline button". # Here we declare utterances and add the localized string # "online/offline". # utterances = [] utterances.append(_("Work online / offline")) # Here we extend the utterances with the speech generator for # the object with focus (the push button). # utterances.extend(speechGen.generateSpeech(event.source)) # Finally we speak/braille the utterances/regions. # speech.speak(utterances) regions = brailleGen.generateBraille(event.source) regions[0].insert(0, self.getNewBrailleRegion(utterances[0] + " ")) self.displayBrailleRegions(regions) return # Here we handle the case when the focus is in the headlines table. # See comment #3 of bug #350233. # http://bugzilla.gnome.org/show_bug.cgi?id=350233 # if orca_state.locusOfFocus.getRole() == \ pyatspi.ROLE_TABLE_COLUMN_HEADER: table = event.source.parent cells = self.utilities.descendantsWithRole( table, pyatspi.ROLE_TABLE_CELL) eventsynthesizer.clickObject(cells[1], 1) default.Script.locusOfFocusChanged(self, event, oldLocusOfFocus, newLocusOfFocus)
def locusOfFocusChanged(self, event, oldLocusOfFocus, newLocusOfFocus): """Called when the visual object with focus changes. Arguments: - event: if not None, the Event that caused the change - oldLocusOfFocus: Accessible that is the old locus of focus - newLocusOfFocus: Accessible that is the new locus of focus """ brailleGen = self.brailleGenerator speechGen = self.speechGenerator debug.printObjectEvent(self.debugLevel, event, event.source.toString()) # Here we handle the case when focus is in the "Work online/offline" # button near the status bar that has an image without a description. # We speak and braille "Online/Offline button" here, until the # developer of the application adds a description to the images # associated with the button, which shows the online or offline # work mode. # rolesList = [ rolenames.ROLE_PUSH_BUTTON, rolenames.ROLE_FILLER, rolenames.ROLE_FILLER, rolenames.ROLE_FRAME ] # We are checking if the button with the focus is the button to # turn on/off the work mode in liferea. This push button is # hierarchically located in the main window of the application # (frame), inside a filler and inside another filler. # if self.isDesiredFocusedItem(event.source, rolesList): # If we are focusing this button we construct a utterance and # a braille region to speak/braille "online/offline button". # Here we declare utterances and add the localized string # "online/offline". # utterances = [] utterances.append(_("Work online / offline")) # Here we extend the utterances with the speech generator for # the object with focus (the push button). # utterances.extend(speechGen.getSpeech(event.source, False)) # Finally we speak/braille the utterances/regions. # speech.speakUtterances(utterances) regions = brailleGen.getBrailleRegions(event.source) regions[0].insert(0, braille.Region(utterances[0] + " ")) braille.displayRegions(regions) return # Here we handle the case when the focus is in the headlines table. # See comment #3 of bug #350233. # http://bugzilla.gnome.org/show_bug.cgi?id=350233 # if orca_state.locusOfFocus.role == rolenames.ROLE_TABLE_COLUMN_HEADER: table = event.source.parent cells = self.findByRole(table, rolenames.ROLE_TABLE_CELL) eventsynthesizer.clickObject(cells[1], 1) default.Script.locusOfFocusChanged(self, event, oldLocusOfFocus, newLocusOfFocus)