Locked What causes get_accName to get called?

  • יום שני 12 מרץ 2012 19:04
     
     

    I am adding accessibility to the product I work on. One of the main issues is that we have a custom spreadsheet that isn't working with accessibility features like Windows Narrator. I tracked it down to the fact that we weren't reporting things to the OS (I am using Inspect to see the accessibility members).

    Since we derive from CWnd I found that all I had to do was add

    EnableActiveAccessibility();

    To the constructor and then override get_accName(). This works awesome. Everytime I click a cell in our spreadsheet, the get_accName method gets called and I report back the cell contents and Inspect sees it great. The problem is that get_accName is only getting called when I click on a new cell. If I use the arrows to navigate from one cell to the next it doesn't get called and Inspect still sees the name of the old cell.

    So my question is, what triggers the OS to ask for accessibility info, in other words what triggers get_accName? Is there a specific call I need to make to tell the OS the name has changed? Why is it firing on some events like LButtonDown but not on others like OnKeyDown?

    Any help is appreciated.


    • נערך על-ידי Jim01 יום שני 12 מרץ 2012 19:06
    •  

כל התגובות

  • יום שני 12 מרץ 2012 19:58
     
     
    Looks like a duplicate of http://social.msdn.microsoft.com/Forums/en-US/windowsaccessibilityandautomation/thread/fe440f6e-2caa-4a2a-a8a3-6080a2de92cf


    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP

  • יום שלישי 13 מרץ 2012 15:00
     
      קוד כלול

    Interesting. Now I have noticed this. When I use a keystroke to change cells nothing changes in Inspect, but 10-12 seconds later the new cell value appears, but I have to be moving the mouse for that to happen. Of course that is an unacceptable behaviour.

    I added this line to the end of OnKeyUp and have verified the line is getting hit, but it doesn't change the behaviour. Am I doing it right?

    NotifyWinEvent(EVENT_OBJECT_NAMECHANGE, OBJID_WINDOW, CHILDID_SELF);

    In case you need to see: Here is the class declaration, and OnKeyUp

    class CUGGrid : public CWnd
    
    void CUGGrid::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) 
    {
    	m_keyRepeatCount = 0;	
    
    	//508
    	NotifyWinEvent(EVENT_OBJECT_NAMECHANGE, OBJID_WINDOW, CHILDID_SELF);
    
    	//CWnd::OnKeyUp(nChar, nRepCnt, nFlags);
    }
    

    • נערך על-ידי Jim01 יום שלישי 13 מרץ 2012 15:11
    •  
  • יום שלישי 13 מרץ 2012 18:14
     
     
    What do you mean 10-12 seconds later the new cell value appears? If you have child object you need to wait until all accessibility children are created before sending EVENT_OBJECT_CREATE.


    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP

  • יום שלישי 13 מרץ 2012 18:22
     
     

    I mean 10-12 seconds later the Name property for my window in inspect will change.

    Here is what I don't understand. After adding the NotifyWinEvent I can fire up AccEvent and see that sure enough it is working. It shows a property event fire and the name is the proper name of the cell, but that value isn't read out through Windows Narrator. Here is a log of me moving around in the grid using arrow keys:

    UIA:PropertyEvent [Name = "MOH"] Sender: ControlType:UIA_PaneControlTypeId (0xC371), Name:"MOH"
    UIA:PropertyEvent [Name = "MR E. MONEY"] Sender: ControlType:UIA_PaneControlTypeId (0xC371), Name:"MR E. MONEY"
    UIA:PropertyEvent [Name = "MR B. TECH"] Sender: ControlType:UIA_PaneControlTypeId (0xC371), Name:"MR B. TECH"
    UIA:PropertyEvent [Name = "1"] Sender: ControlType:UIA_PaneControlTypeId (0xC371), Name:"1"
    UIA:PropertyEvent [Name = "2"] Sender: ControlType:UIA_PaneControlTypeId (0xC371), Name:"2"
    UIA:PropertyEvent [Name = "Unclassified"] Sender: ControlType:UIA_PaneControlTypeId (0xC371), Name:"Unclassified"
    UIA:PropertyEvent [Name = "RDPR"] Sender: ControlType:UIA_PaneControlTypeId (0xC371), Name:"RDPR"
    UIA:PropertyEvent [Name = "100-1066"] Sender: ControlType:UIA_PaneControlTypeId (0xC371), Name:"100-1066"
    UIA:PropertyEvent [Name = "Mohawk Vehicle"] Sender: ControlType:UIA_PaneControlTypeId (0xC371), Name:"Mohawk Vehicle"
    UIA:PropertyEvent [Name = "FPI"] Sender: ControlType:UIA_PaneControlTypeId (0xC371), Name:"FPI"

    As you can see the Name is changing with each stroke, so why isn't narrator reading that out?

    Also, any tips for debugging? If I set a breakpoint in my get_accName I can get out of an infinite loop because once my windows app gets focus then get_accName fires, the breakpoint hits and VS2010 takes the focus. if I try to go to my app it gets focus, the breakpoint hits and over and over. I can never get control of my application because the get_accName will fire when it gets focus. I am trying to just see if get_accName is getting called with a key stroke. Frustrating.

  • יום שלישי 13 מרץ 2012 18:27
     
     
    AccEvent is good for debugging, it looks like the Windows Narrator.is implementing the acc hook differently. Try raise other kinds of events to see how Narrator is updating from other events.


    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP

  • יום שלישי 13 מרץ 2012 18:46
     
     
    Well no here is something interesting. What better comparison for a spreadsheet than Microsoft Excel. I have Excel 2010 and guess what, even though their VPAT seems to say they are compliant, the contents of cells in Excel aren't read by Windows Narrator!! Maybe I am missing something but should Excel be reading cells to be with Narrator?
  • יום שלישי 13 מרץ 2012 21:45
     
     
    Sounds like a problem in Windows Narrator, did you run AccEvent on Excel to see if events are raised? 


    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP

  • יום רביעי 14 מרץ 2012 19:27
     
      קוד כלול

    A couple things.

    First, I noticed that when I double click a cell the contents get read. When a cell is double clicked it turns into an EditControl, based off CEdit which I believe has accessibility built in? Nevertheless here are the events fired when that happens. Does that give a better clue as to what I should be doing?

    UIA:PropertyEvent	[ValueValue = "<unknown type>"] Sender: ControlType:UIA_EditControlTypeId (0xC354), Name:"", AccessKey:"", ValueValue:"EVXDEMO", ValueIsReadOnly:false, LegacyIAccessibleName:[not supported], LegacyIAccessibleRole:[not supported]
    UIA:PropertyEvent	[ValueValue = "<unknown type>"] Sender: ControlType:UIA_EditControlTypeId (0xC354), Name:"", AccessKey:"", ValueValue:"EVXDEMO", ValueIsReadOnly:false, LegacyIAccessibleName:[not supported], LegacyIAccessibleRole:[not supported]
    UIA:PropertyEvent	[ValueValue = "<unknown type>"] Sender: ControlType:UIA_EditControlTypeId (0xC354), Name:"", AccessKey:"", ValueValue:"EVXDEMO", ValueIsReadOnly:false, LegacyIAccessibleName:[not supported], LegacyIAccessibleRole:[not supported]
    UIA:PropertyEvent	[ValueValue = "<unknown type>"] Sender: ControlType:UIA_EditControlTypeId (0xC354), Name:"", AccessKey:"", ValueValue:"EVXDEMO", ValueIsReadOnly:false, LegacyIAccessibleName:[not supported], LegacyIAccessibleRole:[not supported]
    UIA:PropertyEvent	[BoundingRectangle = {l:186 t:129 r:302 b:148}] Sender: ControlType:UIA_EditControlTypeId (0xC354), Name:"", AccessKey:"", ValueValue:"EVXDEMO", ValueIsReadOnly:false, LegacyIAccessibleName:[not supported], LegacyIAccessibleRole:[not supported]
    UIA:PropertyEvent	[BoundingRectangle = "<unknown type>"] Sender: ControlType:UIA_EditControlTypeId (0xC354), Name:"", AccessKey:"", ValueValue:"EVXDEMO", ValueIsReadOnly:false, LegacyIAccessibleName:[not supported], LegacyIAccessibleRole:[not supported]
    UIA:StructureEvent	[StructureChangeType_ChildAdded = TBI<rtid>] Sender: ControlType:UIA_EditControlTypeId (0xC354), Name:"", AccessKey:"", ValueValue:"EVXDEMO", ValueIsReadOnly:false, LegacyIAccessibleName:[not supported], LegacyIAccessibleRole:[not supported]
    UIA:FocusEvent	Sender: ControlType:UIA_EditControlTypeId (0xC354), Name:"", AccessKey:"", ValueValue:"EVXDEMO", ValueIsReadOnly:false, LegacyIAccessibleName:[not supported], LegacyIAccessibleRole:[not supported]
    

    Here are the events fired when my OnKeyUp code fires off:

    UIA:PropertyEvent	[Name = "Mohawk Vehicle"] Sender: ControlType:UIA_PaneControlTypeId (0xC371), Name:"Mohawk Vehicle", AccessKey:"", ValueValue:[Not supported], ValueIsReadOnly:[Not supported], LegacyIAccessibleName:[not supported], LegacyIAccessibleRole:[not supported]
    UIA:PropertyEvent	[Name = "Mohawk Vehicle"] Sender: ControlType:UIA_PaneControlTypeId (0xC371), Name:"Mohawk Vehicle", AccessKey:"", ValueValue:[Not supported], ValueIsReadOnly:[Not supported], LegacyIAccessibleName:[not supported], LegacyIAccessibleRole:[not supported]
    

    I noticed the FocusEvent on the first so I added NotifyWinEvent(EVENT_OBJECT_FOCUS, OBJID_WINDOW, CHILDID_SELF); After the Notify for the name change and it still only fires the two events above in event watcher.

    Secondly, I actually found that the old grid control we were using is still out there as an open source project on codeproject.com. This link has the code and examples. Unfortutunately it still doesn't seem to provide accessibility built in but it might provide you a clearer picture of what I am dealing with.

    The Ultimate Grid Home Page

    a

    a

  • יום רביעי 14 מרץ 2012 20:42
     
     

    Yes I think Edit has accessibility built-in and should be supported by the Narrator. Can you raise the same set of events and see what Narrator do?



    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP

  • יום רביעי 21 מרץ 2012 13:10
     
     תשובה

    I didn't realize there was an accessibility forum on here, so I posted over there and did some searching. According to 

    this post a shortcoming of windows narrator is that it doesn't listen for value/name changes and I need to implement UIAutomation in order to do what I want. I am not going to explore that and hopefully will find good results.

    For anyone searching in the future, my thread in the accessibility forum can be found here.

    • סומן כתשובה על-ידי Jim01 יום רביעי 21 מרץ 2012 13:10
    •