2012-02-10 6 views
0

をクリックすることはできません。カスタムシート:私は私のカスタムシートを作成するには、このソース<a href="http://www.cats.rwth-aachen.de/library/programming/cocoa" rel="nofollow">http://www.cats.rwth-aachen.de/library/programming/cocoa</a></p> <p>を使用するボタン

私は既存の.xibファイルにNSPanelオブジェクトを作成し、IBOutlet

私のソースコードに接続:

の.h

@interface MainDreamer : NSWindow <NSWindowDelegate> 
{  
... 
NSPanel *newPanel; 
} 
... 
@property (assign) IBOutlet NSPanel *newPanel; 

.M

@dynamic newPanel; 
... 

//this method is wired with button on main window and calls a sheet 
- (IBAction)callPanel:(id)sender 
{ 
    [NSApp beginSheet:newPanel 
     modalForWindow:[self window] modalDelegate:self 
     didEndSelector:@selector(myPanelDidEnd:returnCode:contextInfo:) 
      contextInfo: nil]; //(__bridge void *)[NSNumber numberWithFloat: 0] 
} 

//this method is wired with cancel and ok buttons on the panel 
- (IBAction)endWorkPanel:(id)sender 
{ 
    [newPanel orderOut:self]; 
    [NSApp endSheet:newPanel returnCode:([sender tag] == 9) ? NSOKButton : NSCancelButton]; 
} 

//closing a sheet 
- (void)myPanelDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo 
{ 
    if (returnCode == NSCancelButton) return; 
    else{ 
     return; 
    } 
} 

したがってcallPanelはうまくいきますが、シートが表示されますが、シート上のコントロール(ボタン付き)と対話できません。彼らはクリックで反応しません(視覚的にさえ)。

どこに問題がありますか?

答えて

0

ふむ、私はapplicationDidFinishLaunching方法では約

[newDreamPanel close]; 

を忘れてしまいました。メインウィンドウが起動したときにパネルが表示されないようにしたので、私はそれを書きました。

実際には、Visible At LaunchパネルのプロパティをIBでアクティブにする必要があります。 closeメソッドも機能しますが、すべてのコントロールがパネル上で操作できなくなるという副作用があります。

関連する問題

 関連する問題