How to implement an alert sheet with an input text field in Cocoa?


how implement alert sheet input text field?
example, show alert sheet user input password.

know simple usage of nsbeginalertsheet, , haven't read article need. please give me advice or article reference. in advance.
 

i've found method:
- (nsstring *)input: (nsstring *)prompt defaultvalue: (nsstring *)defaultvalue {
nsalert *alert = [nsalert alertwithmessagetext: prompt
defaultbutton:mad:"ok"
alternatebutton:mad:"cancel"
otherbutton:nil
informativetextwithformat:mad:""];

nstextfield *input = [[nstextfield alloc] initwithframe:nsmakerect(0, 0, 200, 24)];
[input setstringvalue:defaultvalue];
[alert setaccessoryview:input];
nsinteger button = [alert runmodal];
if (button == nsalertdefaultreturn) {
[input validateediting];
return [input stringvalue];
} else if (button == nsalertalternatereturn) {
return nil;
} else {
nsassert1(no, @"invalid input dialog button %d", button);
return nil;
}
}

method's performance not want. it's alert window seperated main window. how can make shown sheet main window?
 


Forums Macs Mac Programming


  • iPhone
  • Mac OS & System Software
  • iPad
  • Apple Watch
  • Notebooks
  • iTunes
  • Apple ID
  • iCloud
  • Desktop Computers
  • Apple Music
  • Professional Applications
  • iPod
  • iWork
  • Apple TV
  • iLife
  • Wireless

Comments

Popular posts from this blog

Upgrade Eligibility?

need help with itunes 7.7

How to change Apple IDs on iPhones