[nvda-addons] Re: app dictionaries

  • From: James Scholes <james@xxxxxxxxxxxxx>
  • To: nvda-addons@xxxxxxxxxxxxx
  • Date: Mon, 29 Feb 2016 16:35:18 +0000

Oriol Gómez wrote:

can I create a dictionary for NVDA inside an addon? That is to say...
a dictionary that only loads when an app module is active?

Officially, no.  But you can hack your way around it.  You'll need to
programatically create instances of speechDictHandler.SpeechDictEntry,
append them to an instance of speechDictHandler.SpeechDict which is a
subclass of list, and then monkey patch the speechDictHandler module so
that your app-specific dictionary is included in the loop inside
speechDictHandler.processText.  Alternatively you can just append some
new entry objects to the user's default dictionary.

import speechDictHandler
default_dict = speechDictHandler.dictionaries['default']
my_entry = speechDictHandler.SpeechDictEntry('my pattern', 'my
replacement', comment='')
default_dictionary.append(my_entry)

Whichever route you go down, you must make sure that the entries are
loaded when the application gains focus, and removed when the
application loses focus.  All while making sure you dont slow NVDA to a
crawl.
-- 
James Scholes
http://twitter.com/JamesScholes
----------------------------------------------------------------
NVDA add-ons: A list to discuss add-on code enhancements and for reporting 
bugs. 

Community addons are available from: http://addons.nvda-project.org
To send a message to the list: nvda-addons@xxxxxxxxxxxxx
To change your list settings/unsubscribe: 
//www.freelists.org/list/nvda-addons
To contact list moderators: nvda-addons-moderators@xxxxxxxxxxxxx

Other related posts: