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 (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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to