Re: Inserting additional speech commands based on focus change


Yukio Nozawa
 

Hello Noeria,


It works! In order to avoid duplicated speech, it quits event callbacks chain by not calling nextHandler. Might affect other addons, but I still do not need to care about that since it's currently an experimental phase.


Thank you very much!

On 2021/09/12 15:05, Noelia Ruiz wrote:
Hello, you may do something like this (tested inscratchpad:

import globalPluginHandler
import speech
from speech.commands import PitchCommand
import controlTypes

class GlobalPlugin(globalPluginHandler.GlobalPlugin):

def event_gainFocus(self, obj, nextHandler):
speech.speakObject(obj, controlTypes.OutputReason.FOCUS,
_prefixSpeechCommand=PitchCommand(offset=100))

Please see the new speech.commands.py module, speech.speakObject and
speech.speakObjectProperties methods. Also you can see
speech.sayAll.py to see how the CallBack command canbe implemented

2021-09-11 18:11 GMT+02:00, Yukio Nozawa <personal@nyanchangames.com>:
Hello.


I want to hook the focus change event, see the new control's role and
insert additional speech command sequence so that I can control how the
focused control is announced. It's like more generalized version of
"Beep before cap" where that specific function is handled manually
inside the speech module.


I haven't involved in NVDA addon development for several years. I still
remember that I can set a callback for focus change event, but not sure
if it's possible to insert speech command values and pass them to the
actual speech.speak(speechSequence) call.


speech.getObjectPropertiesSpeech seems to be generating speech sequence
for focused object, but I don't know if intercepting this function is
appropriate.
https://github.com/nvaccess/nvda/blob/f8f62b04e0d15522f9be3beb9e91cce49b540a16/source/speech/speech.py#L411




Any tips for implementing this? Has anyone tried to do similar tweeks?








--
----------

Yukio Nozawa


Keio University

Faculty of Environment and Information Studies

Jun Murai Laboratory. KUMO Research Group

personal e-mail: personal@nyanchangames.com

Website: https://www.nyanchangames.com/

----------

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