开发者

Textfields appearing un-editable when showing back the window using CGDisplay

I am making an application in which:

  1. when user selects display menu option -> the window is displayed over whole screen and
  2. when user selects hide menu option - >the window which was visible over whole screen gets hidden.

Problem is -

When I am performing step 1 then step 2nd then step 1, the window does not appear as it appeared for the first time.

Can anyone suggest me, how can I resolve it?

Below is the part of code:

- (IBAction)hideMenuAction:(id)sender
{   
    [window orderOut:nil];
    if (CGDisplayRelease( kCGDirectMainDisplay ) != kCGErrorSuccess) {
           NSLog( @"Couldn't release the main display!" );
        }
}

- (IBAction)displayMenuAction:(id)sender
{
    [window makeKeyAndOrderFront:nil];
        if (CGDisplayCapture( kCGDirectMainDisplay ) != kCGErrorSuccess) {
           NSLog( @"Couldn't capture the main display!" );
        }
    [window setLevel:CGShieldingWindowLevel()];
}

Edit:

The problem is resolved when I placed the code line: [window makeKeyAndOrderFront:nil]; below the if block in displayMenuAction. The code used is-

- (IBAction)displayMenuAction:(id)sender
{
     if (CGDisplayCapture( kCGDirectMainDisplay ) != kCGErrorSuccess) {
           NSLog( @"Couldn't capture the main display!" );
        }
    [window makeKeyAndOrderFront:nil];
    [window setLeve开发者_开发百科l:CGShieldingWindowLevel()];
}

But I have started facing a new problem:

When I am performing step 1 then step 2nd then step 1, the text fields on window are appearing un-editable. I tried to set them as editable in code but it didn't work.

Please suggest.


Is the window defined in a nib? If so, is the "Release when closed" checkbox active? If it is, when the window is closed it will be deallocated.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜