Guest User

Untitled

a guest
Oct 23rd, 2018
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. func showDialog(buttons: Int8 = 1, question: String, text: String? = nil, confirmButton: String, accessoryView: NSView? = nil, completion: (_ confirm: Bool) -> Void) {
  2. let alert = NSAlert()
  3. alert.messageText = question
  4. alert.addButton(withTitle: confirmButton)
  5.  
  6. if let text = text {
  7. alert.informativeText = text
  8. }
  9.  
  10. if buttons >= 2 {
  11. alert.addButton(withTitle: "Cancel")
  12. }
  13.  
  14. if let accessoryView = accessoryView {
  15. alert.accessoryView = accessoryView
  16. }
  17.  
  18. completion(alert.runModal() == .alertFirstButtonReturn)
  19. }
  20.  
  21.  
  22. let passwordView = NSTextView(frame: NSMakeRect(0, 0, 250, 18))
  23.  
  24.  
  25. Helper.showDialog(question: "Your Password", confirmButton: "Build", accessoryView: passwordView) {_ in
  26. //
  27. }
Add Comment
Please, Sign In to add comment