[nvda-addons] Re: Developing Addons - The best way to get started?

  • From: "Damien Sykes-Pendleton" <damien@xxxxxxxxxxxxxxxxxxxx>
  • To: <nvda-addons@xxxxxxxxxxxxx>
  • Date: Fri, 15 Apr 2016 11:35:07 +0100

Hi James,
Very interesting. So the log tells you everything you need to know? If so that sounds a lot easier than I expected.
Still, all your code snippet has to do is navigate to the next object. The object I'm interested in is two objects above in the hierarchy. The listbox focuses on the list item, then you go up to the listbox, then up to the window above that, all the summary information is on that level, but it's not always in the same place consistently. It all depends on whether the person has a relationship to yourself, how many marriages they have, how many children they have etc.
Kind regards,
Damien.
-----Original Message----- From: James Scholes
Sent: Friday, April 15, 2016 10:58 AM
To: nvda-addons@xxxxxxxxxxxxx
Subject: [nvda-addons] Re: Developing Addons - The best way to get started?

Damien Sykes-Pendleton wrote:

I've no idea how this code works so wouldn't know how to translate it to
my specific problem. How do I know where the listbox is in relation to
the static text? How can I get the text from all six controls? That kind
of thing.

Like I said, forget the six controls for the moment.  Focus on
understanding how to obtain text from one of them, then you can
implement the solution for them all.

As for the location of the static controls in relation to the list box,
figuring this out isn't too different from generally working out how to
use a program by tabbing around.  Only with this, you have to use object
nav.  If you're not overly familiar with object navigation, you'll need
to be.

Previously, somebody recommended disabling simple review mode.  If
you've done so, I'd recommend turningg it back on.  It shouldn't be
necessary for this exercise.

1. Tab to the list box, and select a name.
2. Using object nav, find one of the static controls.
3. Repeat this process until you can safely say you know how to do it
consistently every single time.
4. Implement the same movement in code.  This is where NVDA's Python
console comes in very handy, as whenever you open it, a snapshot of the
current focus is taken and stored in a number of variables.  The most
useful of these is probably nav, which will be set to the current
navigator object.  If you haven't played around with it yet, do give it
a try.

I realise that this is all very nnew to you.  However, developing NVDA
add-ons is often a case of trial and error.  I'll also explain how the
code snippet I posted works, so you have a better idea of what I'm
talking about.

In foobar2000, while focussed on a slider, you can usually use object
navigation to move to the next object on the right, and find a static
text field with a more useful value for that slider.  For instance, if
you're adjusting the length of a fade, the static text control will have
the current length in milliseconds.

Thus, the code that I posted sets up an event listener for valueChange
events.  This function inside my app module will be called every time
the value of a control changes inside foobar2000.  However, we're only
interested in processing events for certain sliders, so the function
first checks that the object's role is that of a slider, and then that
it's control ID is listed in an array of control IDs that I previously
identified by tabbing around, finding sliders, and using the NVDA log
viewer to locate their windowControlID property.

If the control in question is indeed one of our sliders, I tell NVDA to
locate the next object, which is the same as moving one object to the
right with object nav from the keyboard.  I then tell it to speak the
name of the control that it finds, using the ui.message function.  If
the control isn't one that we're interested in, I tell NVDA to move on
and process the event as it wants to.

In practical terms, this implementation means that when I move a slider
with the arrow keys, a more appropriate value is spoken e.g. 4000ms
instead of 11%.  Now that I've explained how it works, try to look
through the code and see if you can spot the bits that I've described
and how they work.  The only difference between this code and yours will
be the fact that you're monitoring changes in a list box, not sliders.
--
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
----------------------------------------------------------------
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: