0

I created a cocos2d-x project and there is a class called AppController.mm where an EAGLView object (__glView) is created. The accessibility of __glView is set to true/yes by default but I want it to be false/no so I can access my elements which are behind the EAGLView with an automation tool like UI Automation Tool by Xcode. Now when I try to set the accessibility of that view to false, I use that line of code in AppController.mm after it's created:

[__glView setIsAccessibilityElement:NO];

But this setter doesn't do anything. It ignores that and is still true/yes. In a test project, I override the getter in EAGLView.mm like this:

- (BOOL) isAccessibilityElement
{
    return NO;
}

and it works perfectly fine. The problem in my real project is, that I don't have access to EAGLView.mm so I thought using the setter would be nice but it doesn't do anything.

If I use

[__glView setAccessibilityElementsHidden:YES]

then it works (doesn't ignore it) but of course everything is hidden, so I can't even have access to my own elements which are under EAGLView. I just want to hide this specific __glView.

Southgarden116
  • 311
  • 3
  • 16
  • Have you checked that __glView is non-nil when you send the setIsAccessibilityElement message? Btw often setters for BOOL properties beginning with "is" aren't named setIs.. but simply setAccessibilityElement. You might want to try that, or simply use dot notation: __glView.isAccessibilityElement = NO; or __glView.accessibilityElement = NO; whichever works. – CodeSmile Apr 02 '14 at 08:44
  • Thanks but it is with setIs.. it even gets suggested, there is no `setAccessibilityElement` only `setAccessibilityElementsHidden`. And i tried with the dot notation, still the same problem, it gets ignored so it is still `YES`. – Southgarden116 Apr 02 '14 at 08:58
  • And is __glView non-nil at that point where you try to change accessibility? If it's nil, Objective-C will ignore the message rather than crashing as C/C++ would when dereferencing a NULL pointer. – CodeSmile Apr 02 '14 at 08:59
  • `__glView` is not nil, but thanks for helping. – Southgarden116 Apr 02 '14 at 09:50

0 Answers0