Guest User

Untitled

a guest
Aug 18th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. framework 'AppKit'
  2.  
  3. class AppDelegate
  4. def windowWillClose(notification)
  5. exit
  6. end
  7.  
  8. def yes(sender)
  9. puts "YES!"
  10. end
  11.  
  12. def no(sender)
  13. puts "NO!"
  14. end
  15. end
  16.  
  17. app = NSApplication.sharedApplication
  18. app.delegate = AppDelegate.new
  19.  
  20. window = NSWindow.alloc.initWithContentRect([500, 400, 300, 100],
  21. styleMask:NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask,
  22. backing:NSBackingStoreBuffered, defer:false)
  23. window.title = 'MacRuby: Button'
  24. window.level = NSModalPanelWindowLevel
  25. window.delegate = app.delegate
  26.  
  27. y_button = NSButton.alloc.initWithFrame([20, 0, 100, 100])
  28. y_button.bezelStyle = 1
  29. y_button.title = 'YES!'
  30. y_button.target = app.delegate
  31. y_button.action = 'yes:'
  32.  
  33. n_button = NSButton.alloc.initWithFrame([180, 0, 100, 100])
  34. n_button.bezelStyle = 1
  35. n_button.title = 'NO!'
  36. n_button.target = app.delegate
  37. n_button.action = 'no:'
  38.  
  39. window.contentView.addSubview(y_button)
  40. window.contentView.addSubview(n_button)
  41.  
  42. window.display
  43. window.orderFrontRegardless
  44. app.run
Add Comment
Please, Sign In to add comment