Re: NSControl subclass and accessibility
Thank you. Eyal > On 13 Mar 2022, at 18:31, Rob Petrovec 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 >> 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 >> >> @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 (Cocoa-dev@lists.apple.com) >> >> 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: >> https://lists.apple.com/mailman/options/cocoa-dev/petrock%40mac.com >> >> This email sent to petr...@mac.com > ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSControl subclass and accessibility
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 > 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 > > @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 (Cocoa-dev@lists.apple.com) > > 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: > https://lists.apple.com/mailman/options/cocoa-dev/petrock%40mac.com > > This email sent to petr...@mac.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSControl subclass and accessibility
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 @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 (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com