0

In normal case, a blue retangle would appear outside a NSTextField object which becomes the first responder, like this image:
link for Normal Case

However, I got a NSTextField that have no the blue border outside. Why is that?

Here is how it happerns:
1> I create a typical MAC OS app.
2> I switch app's subview by calling the corresponding view's addSubview: and removeFromSuperview methods.
3> In one subview (which is actually the image referenced above) I click the "Next" button. Its action is something like this (defined in the subview's controller .m file):

- (IBAction)actionNextClicked:(id)sender{
//_hdlThreadNext is a NSThread object
    [[_hdlThreadNext alloc] initWithTarget:self selector@selector(threadNext:) object:nil];
    [_hdlThreadNext start];
}

And the thread is like:

- (void)threadNext:(id)sender{
    @autoreleasepool{
         BOOL success;

         [CATransation begin];

         /* send username and password and decrypt responce */
         ... // balabala... and set "success"

         if (success){
             [[self view] removeFromSuperview];
             [self sendMessageToSuperview:@"Add Next View"];    // Superview's method, telling superview to call addSubview: to add another subview
         }
         else{
             /* Nothing special to do */
         }

         [CATransation commit];
    }
}

4> The subview switch to another one. Its combo view seemed to be OK: image for combo view
But the other NSTextView's blue border would NOT appear anymore!

Does Any guy know what wrong I had done? Thank you very much!

Andrew Chang
  • 1,289
  • 1
  • 18
  • 38

1 Answers1

0

Perhaps I did totally wrong programming, so that few people met this problem.
I found a way to solve this problem. I mentioned that all (or most of?) the graphic changes should be done in main thread in a blog. Therefore I change the "if(success)" as:

if(success){
    dispatch_async(dispatch_get_main_queue()' ^{
        [[self view] removeFromSuperview];
        [self sendMessageToSuperview:@"Add Next View"];
    });
}

Solved, the focus rings come back.

Andrew Chang
  • 1,289
  • 1
  • 18
  • 38