Addon development: how to switch focus to another NVDA object?


Samuel Kacer
 

Hello all,

 

I am currently developing an addon and I am trying to figure out how to have NVDA jump to another NVDA object.

 

Essentially I am wanting for when the user presses NVDA + E, the current focused object’s siblings are searched and the first one that is editable text is focused. Here is my code:

    @script(gesture = 'kb:NVDA+e')

    def script_findEditor(self, gesture):

        # get the first sibling of focused object

        obj = api.getFocusObject().simpleParent.simpleFirstChild

        while obj is not None:

            if obj.role is controlTypes.ROLE_EDITABLETEXT:

                obj.setFocus()

                return

            obj = obj.simpleNext

        ui.message('couldnt find editor.')

 

 

I am developing this for use in IntelliJ which uses Java Access Bridge GUI. It does not work as expected, if the object doesn’t have a editor sibling it correctly outputs the message, but if it does, it doesn’t output the message and nothing happens.

 

Some help in understanding why it might not be working is greatly appreciated.

 

Kind Regards,

Sam

 

 

Join nvda@nvda.groups.io to automatically receive all group messages.