Re: -[NSView lockFocus] assertion failure
Re: -[NSView lockFocus] assertion failure
- Subject: Re: -[NSView lockFocus] assertion failure
- From: "John C. Randolph" <email@hidden>
- Date: Fri, 17 Apr 2009 04:35:43 -0700
On Apr 15, 2009, at 5:52 PM, James G. wrote:
I've got an NSTextField within a layer-backed view, with several other
layers. The text field sits hidden on top of two other CALayers.
When the
view is double clicked, the NSTextField is unhidden, to allow the
user to
edit the text. When the user completes the editing, I want to hide the
NSTextField, as an animated CATextLayer will begin playing beneath the
textField. When I attempt to hide the NSTextField and begin the
animation, I
get the NSView lockFocus assertion failure.
I hide the NSTextField in the action method, and begin the animation
on the
lower layer. The NSTextField.hidden property is bound to
textFieldIshidden
of marqueeView. The assertion failure occurs even when I comment out
the
animation call. Looking at the stack trace, it looks like a problem
drawing
the focusRing, although I've set the focusRingType to
NSFocusRingTypeNone.
Is there a more appropriate place to hide the textField, in order to
show
the animation below it?
Method below is set as the action of the NSTextField.
- (IBAction)processTextField:(id)sender {
NSLog(@"processTextField:");
[marqueeView setTextFieldIsHidden:YES];
[marqueeView animateMarquee];
}
I suspect the problem is that -animateMarquee is trying to lock
focus in the midst of a redraw that's caused by hiding the text field.
Try:
- (IBAction)processTextField:(id)sender {
NSLog(@"processTextField:");
[marqueeView setTextFieldIsHidden:YES];
[marqueeView performSelector:@selector(animateMarquee)
withObject:nil afterDelay:0 cancelPrevious:YES];
}
This will give marqueeView the opportunity to finish removing the
textfield from view before you start animating it.
-jcr
_______________________________________________
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