Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c Cocos2d项目中Mac上的可编辑NSTextField_Objective C_Macos_Cocoa_Cocos2d Iphone - Fatal编程技术网

Objective c Cocos2d项目中Mac上的可编辑NSTextField

Objective c Cocos2d项目中Mac上的可编辑NSTextField,objective-c,macos,cocoa,cocos2d-iphone,Objective C,Macos,Cocoa,Cocos2d Iphone,我试图在Cocos2d项目中的Mac上显示可编辑的NSTextField。我直接从AppDelegate运行我的所有测试代码,以使测试简单并消除所有副作用。下面的代码显示带有漂亮编辑字段的红色窗口。问题在于该字段看起来没有焦点(文本选择是灰色的),并且不可编辑(没有光标,也没有对按键笔划的反应)。我可以用鼠标更改文本选择,但仅此而已 有什么不对劲的暗示吗 - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {

我试图在Cocos2d项目中的Mac上显示可编辑的NSTextField。我直接从AppDelegate运行我的所有测试代码,以使测试简单并消除所有副作用。下面的代码显示带有漂亮编辑字段的红色窗口。问题在于该字段看起来没有焦点(文本选择是灰色的),并且不可编辑(没有光标,也没有对按键笔划的反应)。我可以用鼠标更改文本选择,但仅此而已

有什么不对劲的暗示吗

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    CCDirectorMac *director = (CCDirectorMac*) [CCDirector sharedDirector];
    [glView_ setFrameSize:NSMakeSize(1024,768)]; 
    [director setOpenGLView:glView_];
    [director setResizeMode:kCCDirectorResize_AutoScale];
    [glView_ setFrameSize:NSMakeSize(window_.frame.size.width,window_.frame.size.height-20)]; 
    [window_ setContentAspectRatio:NSMakeSize(1024,768)];
    [window_ setAcceptsMouseMovedEvents:NO];

    [self addOverlayWindow];

    //[director runWithScene:[MCGameScene scene]/*[HelloWorldLayer scene]*/];
}

- (void) addOverlayWindow;
{
    NSRect windowRect = [[window_ contentView] frame] ;
    NSWindow* uiWindow  = [[NSWindow alloc]  initWithContentRect:windowRect
                                     styleMask:NSBorderlessWindowMask
                                       backing:NSBackingStoreBuffered defer:YES];
    [uiWindow setBackgroundColor: [NSColor redColor/*clearColor*/]];
    [uiWindow setOpaque:NO];

    NSView* uiView = [[[NSView alloc] initWithFrame:NSMakeRect(0, 0, windowRect.size.width, windowRect.size.height)] autorelease];
    [uiView translateOriginToPoint:NSMakePoint(100, uiView.bounds.size.height/2)];
    uiView.wantsLayer   = YES;

    [uiWindow setContentView:uiView];

    NSTextField *textField;
    textField = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 800, 80)];
    [textField setFont:[NSFont fontWithName:@"Helvetica Bold" size:60]];
    [textField setStringValue:@"My XXXXXXXXX Label"];
    [textField setBezeled:YES];
    [textField setDrawsBackground:YES];
    [textField setEditable:YES];
    [textField setSelectable:YES];
    [textField setEnabled:YES];

    [uiView addSubview:textField];

    // None of these combinations works...
    //    [textField becomeFirstResponder];
    //    [uiWindow setInitialFirstResponder:textField];
//    [uiWindow makeFirstResponder:textField];
    //[window_ makeFirstResponder:textField];
      [window_ setInitialFirstResponder:textField];
//    [uiView setInitialFirstResponder:textField];
    //    [uiView makeFirstResponder:textField];

    [window_ addChildWindow:uiWindow ordered:NSWindowAbove];
}
提前感谢您的帮助, --约瑟夫