2012-12-03 2 views
0

Mac OS X NSTabView : 키보드 탐색을 위해 TabItem의보기를 표시하려면 어떻게합니까?NSTabView 키보드 이벤트가있는 Mac OS X NSPanel : NSTabViewDelegate를 사용하여 키보드 탐색을 위해 TabItem의보기를 표시하려면 어떻게해야합니까?

저는 마우스로 잘 동작하는 TabView를 가지고 있습니다. NSTabView 지원 키보드 탐색을 만들고 싶습니다.

화살표 키를 사용하면 여러 TabItem을 이동하지만, 의 TabItem보기는 나타나지 않습니다. 탭보기를 표시하려면 탭을 클릭해야합니다. 화살표 키를 사용

의 NSTabViewDelegate 방법

tabView:shouldSelectTabViewItem: 

가 호출이 YES를 반환한다. 다른 NSTabViewDelegate 메서드가 호출되지 않으므로 View가 표시되지 않습니다.

마우스 클릭 (보기 표시) 조치가 TabItem의 키보드를 사용 도달하면 해고를 얻을 수있는 가장 좋은/권장하는 방법은 무엇입니까? Xcode 에서이 문제를 해결할 수 있습니까? 아니면 서브 클래 싱 및/또는 알림이 필요합니까?

답변

0

내부 MyAppController (MainWindow를) 응용 프로그램은 원래 editRecipeController의 창,있는 NSPanel을 넣어이 코드를 사용

시트 창 내부

[NSApp beginSheet:[editController window] modalForWindow:[self window] modalDelegate:nil didEndSelector:nil contextInfo:nil]; 
    [NSApp runModalForWindow:[editController window]]; 
    // sheet is up here... 
    [NSApp endSheet: [editController window]]; 
    [[editController window] orderOut:nil]; 
    [[editController window] close]; 

,로 EditWindow을 시작하기 // 원본 코드 NSPanel, NSTabView가 있습니다. 패널은 마우스를 사용하여 완전히 작동합니다. 그것에는 5 개의 탭 NSTabView가 있습니다. 하나의 탭에는 NSTextField가 있고, 3 개의 탭에는 NSTextView가 있습니다. 다섯 번째에는 NSTableView가 있습니다.

내가 가진 문제이 (가) ArrowKey, 적절한 탭 강조했다을 사용하여 탭으로 탭에서 탐색 사용자 만이되지 않았다가, 즉, "선택"의보기가 표시되지 때, 다음과 같이이었다. 뷰를 표시하는 유일한 방법은 마우스로 탭을 클릭하는 것입니다.

My goal is to have full keyboard support for the NSTabView 

내가 따라 NSTabView에 대한 적절한 동작을 얻을 수있었습니다 :. Hillegass '책, 25 장, "시트를

// MyAppController.m - WindowController for mainWindow 

    - (IBAction) editRecipeAction:(id)sender { 
     // setup the edit sheet controller if one hasn't been setup already 
     if (editRecipeController == nil){ 
      editRecipeController = [[EditRecipeController alloc] initWithWindowNibName:@"EditRecipe"]; 
      //[editRecipeController setMyAppController:self]; 
     } 

     [[NSApplication sharedApplication] beginSheet:editRecipeController.window 
        modalForWindow:self.window 
         modalDelegate:editRecipeController 
        didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) 
         contextInfo:nil]; 
    } 

// 끝 MyAppController.m

// EditRecipeController.m

- (IBAction)cancel:(id)sender 
    { 

     [NSApp endSheet:self.window returnCode:0 ] ; 
     [self.window orderOut:self]; 
    } 

- (void) sheetDidEnd:(NSWindow *) sheet returnCode:(int)returnCode contextInfo:(void *) contextInfo { 

    DLog(@"sheet=%@",sheet); 

} 

목표가 완전 키보드 지원이면

- (void)tabView:(NSTabView *)aTabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem{ 

     NSNumberFormatter * f = [[NSNumberFormatter alloc] init]; 
     [f setNumberStyle:NSNumberFormatterDecimalStyle ]; 
     NSNumber *tabNumber = 
     [f numberFromString:tabViewItem.identifier]; 
     [f release]; 

     switch (tabNumber.integerValue) { 
      case 1: 
       editRecipeController.tabView.nextKeyView = editRecipeController.textViewIngredients; 
       editRecipeController.textViewIngredients.nextKeyView = editRecipeController.cancelButton; 
       editRecipeController.cancelButton.nextKeyView = editRecipeController.doneButton; 
       editRecipeController.doneButton.nextKeyView = editRecipeController.tabView; 
       break; 
      case 2: 
       editRecipeController.tabView.nextKeyView = editRecipeController.textViewDirections; 
       editRecipeController.textViewDirections.nextKeyView = editRecipeController.cancelButton; 
       editRecipeController.cancelButton.nextKeyView = editRecipeController.doneButton; 
       editRecipeController.doneButton.nextKeyView = editRecipeController.tabView; 
       break; 
      case 3: 
       editRecipeController.tabView.nextKeyView = editRecipeController.textViewDirections; 
       editRecipeController.textViewDirections.nextKeyView = editRecipeController.cancelButton; 
       editRecipeController.cancelButton.nextKeyView = editRecipeController.doneButton; 
       editRecipeController.doneButton.nextKeyView = editRecipeController.tabView; 
       break; 
      case 4: // Comments 
       editRecipeController.tabView.nextKeyView = editRecipeController.textViewComments; 
       editRecipeController.textViewComments.nextKeyView = editRecipeController.cancelButton; 
       editRecipeController.cancelButton.nextKeyView = editRecipeController.doneButton; 
       editRecipeController.doneButton.nextKeyView = editRecipeController.tabView; 
       break; 
      case 5: //Categories - Table can not be edited 
       editRecipeController.tabView.nextKeyView = editRecipeController.cancelButton; 
       editRecipeController.cancelButton.nextKeyView = editRecipeController.doneButton; 
       editRecipeController.doneButton.nextKeyView = editRecipeController.tabView; 
       break; 
      default: 
       DLog(@"switch value error"); 
       break; 
     }// end switch 

    } 
: 등이 NSTabView, 나는 당신이 NSTabViewDelegate 방법의 다음 사용 같은 것을 가 필요합니다 생각
관련 문제