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: Ross Carter <email@hidden>
- Date: Tue, 24 Nov 2009 15:18:52 -0500
On Nov 24, 2009, at 1:37 PM, James Dempsey wrote:
>
> On Nov 24, 2009, at 10:28 AM, Christiaan Hofman wrote:
>
>>
>> On Nov 24, 2009, at 19:17, James Dempsey wrote:
>>
>>>
>>> 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
>>>
>>
>> Animating setHidden is definitely not supported. Typically only continuous properties are animatable. An exception is removeFromSuperview that can fade out a view. But anyway, this is not what I understand the OP wants, I guess he wants to collapse the view rather than fade it out. In that case you should use setHidden: at the end of the animation, either using a custom CAAnimation with a delegate, or something like this:
>>
>> [view performSelector:@selector(hideView:) withObject:view afterDelay:[[NSAnimationContext currentContext] duration]];
>>
>> and hideView: is simply implementing by calling setHidden: on the view (this could also be implemented in an NSView category, with minor changes to the above code).
>>
>> Christiaan
>
> Yes, the delegate or what you are suggesting should also work.
>
> Again, please file an enhancement request regarding giving animation effects to setHidden:. It seems that would be a common usage of animations.
For my purposes, it sounds like all I have to do is, in my custom view:
- (void)setFrame:(NSRect)rect {
[super setFrame:rect];
[self setHidden:rect.size.height <= 0.0];
}
That should hide the view at the end of the collapsing animation, and show it at the start of the expanding animation, which I guess is the preferred behavior.
_______________________________________________
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