Re: Refresh focus


Ramón García
 

Thanks for your answer. F5 worked but I can't set the focus to that new file yet.

def script_newFile(self, gesture):
fgObj = api.getForegroundObject()
route = ""
route += self.getRoute(fgObj) # This method return the folder route
file = open(route+'\\newFile.txt','a+')
file.close()
KeyboardInputGesture.fromName("f5").send()
obj = api.getFocusObject()
for itemObj in obj.parent.children:
if itemObj.name == u"newFile.txt":
api.setFocusObject(itemObj)

-----Mensaje original-----
De: nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> En nombre de Noelia Ruiz
Enviado el: domingo, 31 de julio de 2022 19:39
Para: nvda-addons@nvda-addons.groups.io
Asunto: Re: [nvda-addons] Refresh focus

Welcome.
You may show your source code for a better reply. I'd try with the
redraw() method obj.redraw() or sending the f5 key to the system:
from keyboardHandler import KeyboardInputGesture
KeyboardInputGesture.fromName("f5").send()



2022-07-31 15:53 GMT+02:00, Ramón García via groups.io
<rgmagadan@...>:

Hi everyone,

My name is Ramón, from Spain. I am glad to be here.

I would like to ask you something about a script I am writing.

I am in Windows Explorer. There are 5 items in the list view (obj.parent).

I press the script gesture and a new item is created in that folder.

Now I would like to set the focus to the new item, but when I check
the children of the list view (obj.parent.childCount), the same 5 items appear.

Is there a way I can force to NVDA to refresh the view list from the
script?

I tried changing the focus from a list item to the list view after the
new file was created but did not work,

I appreciate your answer.

Regards.






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