Re: NSControl subclass and accessibility
Re: NSControl subclass and accessibility
- Subject: Re: NSControl subclass and accessibility
- From: Eyal Redler via Cocoa-dev <email@hidden>
- Date: Sun, 13 Mar 2022 22:49:56 +0200
Thank you.
Eyal
> On 13 Mar 2022, at 18:31, Rob Petrovec <email@hidden> wrote:
>
> Accessibility for NSControls is handled by the NSCell inside it, not the
> NSControl. Good luck.
>
> —Rob
>
>
>> On Mar 13, 2022, at 7:55 AM, Eyal Redler via Cocoa-dev
>> <email@hidden> wrote:
>>
>> Hi,
>>
>> I'm having trouble getting a custom NSControl subclass properly visible with
>> regards to accessibility.
>>
>> If I implement my custom control as an NSView subclass and adopt the
>> NSAccessibilityButton protocol, I can "see" my custom control with
>> accessibility inspector when I hover above it.
>> If I take the same class but make it a subclass of NSControl, I'm not able
>> to "see" my control using accessibility inspector when hovering above it. It
>> is detecting something because I can see that when I hover in the containing
>> view, I can see the window ui element, but when I hover above the control
>> itself, I'm only seeing the "app" element. Also, when I inspect the
>> containing view I can see my control listed there and I can access it and
>> perform the action.
>>
>> I feel like I'm missing something obvious. Any ideas?
>>
>> Here's my code, If I replace NSControl with NSView, it seems to work great.
>>
>> @interface MyFancyButton : NSControl <NSAccessibilityButton>
>>
>> @end
>>
>> @implementation MyFancyButton
>> - (void)drawRect:(NSRect)dirtyRect ...
>>
>> - (void)mouseDown:(NSEvent *)event ...
>>
>> - (void)simulateClick ...
>>
>>
>> - (nullable NSString *)accessibilityLabel
>> {
>> return @"my_label";
>> }
>> - (BOOL)accessibilityPerformPress
>> {
>> [self simulateClick];
>> return YES;
>> }
>> @end
>>
>> Thanks in advance,
>>
>>
>>
>>
>> Eyal Redler
>> ------------------------------------------------------------------------------------------------
>> "If Uri Geller bends spoons with divine powers, then he's doing it the hard
>> way."
>> --James Randi
>> www.eyalredler.com
>>
>>
>> _______________________________________________
>>
>> Cocoa-dev mailing list (email@hidden)
>>
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden