문제

I have a NSPanel. I use the following code:

[NSApp beginSheet:<NSPanel>
       modalForWindow:[[self view] window]
        modalDelegate:self 
       didEndSelector:nil 
          contextInfo:nil];

This Panel has a view that contains a NSTextField. For some condition with NSTextField text, i need to display an Alert on top of the NSPanel View. Code for throwing Alert:

NSBeginAlertSheet(@"OK", @"Cancel", nil,nil, [[self view] window], self, nil,  nil,nil, @"Error");

Any idea how can i achieve this?

도움이 되었습니까?

해결책

Got the solution. Need to override NSControlTextEditingDelegate method with the following:

- (void)control:(NSControl *)control didFailToValidatePartialString:(NSString *)string errorDescription:(NSString *)error

{
       NSBeginAlertSheet(@"OK", @"Cancel", nil,nil, <NSPanel instance>, self, nil,  nil,nil, @"Error");

}

:) :)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top