Re: Hiding children of view with height == 0
Re: Hiding children of view with height == 0
- Subject: Re: Hiding children of view with height == 0
- From: James Dempsey <email@hidden>
- Date: Tue, 24 Nov 2009 10:17:23 -0800
On Nov 24, 2009, at 9:44 AM, Ross Carter wrote:
> Thanks, Patty and Mike, for quickly answering my question about NSSegmentedControl.
>
> I have some NSView subclasses that are hidden from view by setting their height to 0. I use this rather than setHidden:NO because the height is set by an animation, which makes the views look like they are rolling up.
>
> It looks like AX subviews of hidden views, but not views that have 0 height or views that are not visible on screen because they are clipped. In those situations, I am doing this in the view subclass:
>
> - (id)accessibilityAttributeValue:(NSString *)attribute {
> if ([attribute isEqualToString:NSAccessibilityChildrenAttribute]) {
> if ([self frame].size.height < 1.0) {
> return nil;
> }
> }
> return [super accessibilityAttributeValue:attribute];
> }
>
> Is that the correct approach?
Even if you change the height of the view through an animation to make it visually 'appear' and 'disappear', you should still set the view to be hidden when it is hidden, and not hidden when it is not hidden using setHidden:.
Before Cocoa added isHidden/setHidden: was added, way back in Panther, I know developers needed to play tricks with setting heights or widths to 0, or moving something out of the window's coordinate space so it wouldn't draw.
But now that we have it, definitely use setHidden: to hide and show views as they disappear and appear.
If you have not already done so, you may want to investigate using a custom animation for changing the isHidden view property. You can attach custom animations to changing view properties starting in 10.5. Off the top of my head I don't know what set of property keys can be customized, or if it would be possible to attach the frame change animation to be triggered by setting setHidden:. Ideally you would set a custom hide/show animation that does what you want, and you would only need to call:
[[view animator] setHidden:YES];
[[view animator] setHidden:NO];
You may have investigated that approach and perhaps it is not supported by the current animation proxy implementation. If so, please file an enhancement request, it seems it would make a lot of sense to support various visual effects of views coming and going using setHidden: and the animator proxy.
-James
--------------------------------------------------
James Dempsey
AppKit Engineering
Apple
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Accessibility-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden