speaking the character that the cursor is on in an application

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

speaking the character that the cursor is on in an application

Ryan Mann

When the cursor in an edit box changes, I am trying to get NVDA to speak the character that the cursor is on.  With the below code, I get an index out of range error.

class AppModule(appModuleHandler.AppModule):

               

                def event_valueChange(self, obj, nextHandler):

                                perky=api.getFocusObject().makeTextInfo(textInfos.POSITION_CARET)

                                text=perky.text

                                ui.message(text)

                                nextHandler()


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Nvda-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nvda-devel
Reply | Threaded
Open this post in threaded view
|

Re: speaking the character that the cursor is on in an application

derek riemer
You need to expand the textinfo to the character. This starts out at the collapsed position of the carret.
assuming your textInfo is ti and the caret is on a in a line "nvda is great."

ti.expand(textInfos.UNIT_CHARACTER)
ti.text #a
ti.expand(textInfos.UNIT_WORD)
ti.text #NVDA
ti.expand(textInfos.UNIT_LINE)
ti.text #The whole line
and so on.

On Sun, Jul 9, 2017 at 6:53 PM, Ryan Mann <[hidden email]> wrote:

When the cursor in an edit box changes, I am trying to get NVDA to speak the character that the cursor is on.  With the below code, I get an index out of range error.

class AppModule(appModuleHandler.AppModule):

               

                def event_valueChange(self, obj, nextHandler):

                                perky=api.getFocusObject().makeTextInfo(textInfos.POSITION_CARET)

                                text=perky.text

                                ui.message(text)

                                nextHandler()


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Nvda-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nvda-devel




--

Derek Riemer: Improving the world one byte at a time!

  • University of Colorado Boulder Department of computer science, 4th year undergraduate student.
  • Accessibility enthusiast.
  • Proud user of the NVDA screen reader.
  • Open source enthusiast.
  • Skier.

Personal website



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Nvda-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nvda-devel