osx - Dialog like Xcode in OS X -


i want show dialog text input sheet below.

enter image description here

i try nsalert don't want show app icon in dialog.

nsalert *alert = [[nsalert alloc] init]; [alert setmessagetext:kapptitle]; [alert setinformativetext:kmsgsetdevicename]; [alert addbuttonwithtitle:kbuttonok]; [alert addbuttonwithtitle:kbuttoncancel];  nsstring *devicename = @"";  nstextfield *input = [[nstextfield alloc] initwithframe:nsmakerect(0, 0, 300, 24)]; [input setstringvalue:devicename];  [alert setaccessoryview:input]; [alert beginsheetmodalforwindow:self.view.window completionhandler:^(nsinteger button) {  }];  

you can use http://www.knowstack.com/nsalert-cocoa-objective-c/ link create custom alert sheet in osx.

-(void)showcustomsheet {  {  if (!_customsheet)  //check mycustomsheet instance variable make sure custom sheet not exist.  [nsbundle loadnibnamed: @"customsheet" owner: self];  [nsapp beginsheet: self.customsheet  modalforwindow: self.window  modaldelegate: self  didendselector: @selector(didendsheet:returncode:contextinfo:)  contextinfo: nil];  // sheet here.  } } - (ibaction)closemycustomsheet: (id)sender {  [nsapp endsheet:_customsheet]; } - (void)didendsheet:(nswindow *)sheet returncode:(nsinteger)returncode contextinfo:(void *)contextinfo {  nslog(@"%s",__func__);  nslog(@"return code %d",returncode);  [sheet orderout:self]; } 

the below method required have different point show alert from

- (nsrect)window:(nswindow *)window willpositionsheet:(nswindow *)sheet  usingrect:(nsrect)rect {  nslog(@"%s",__func__);  if (sheet == self.customsheet)  {  nslog(@"if block");  nsrect fieldrect = [self.showalertbutton frame];  fieldrect.size.height = 0;  return fieldrect;  }  else  {  nslog(@"else block");  return rect;  } } 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -