Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- framework 'AppKit'
- class AppDelegate
- def windowWillClose(notification)
- exit
- end
- def yes(sender)
- puts "YES!"
- end
- def no(sender)
- puts "NO!"
- end
- end
- app = NSApplication.sharedApplication
- app.delegate = AppDelegate.new
- window = NSWindow.alloc.initWithContentRect([500, 400, 300, 100],
- styleMask:NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask,
- backing:NSBackingStoreBuffered, defer:false)
- window.title = 'MacRuby: Button'
- window.level = NSModalPanelWindowLevel
- window.delegate = app.delegate
- y_button = NSButton.alloc.initWithFrame([20, 0, 100, 100])
- y_button.bezelStyle = 1
- y_button.title = 'YES!'
- y_button.target = app.delegate
- y_button.action = 'yes:'
- n_button = NSButton.alloc.initWithFrame([180, 0, 100, 100])
- n_button.bezelStyle = 1
- n_button.title = 'NO!'
- n_button.target = app.delegate
- n_button.action = 'no:'
- window.contentView.addSubview(y_button)
- window.contentView.addSubview(n_button)
- window.display
- window.orderFrontRegardless
- app.run
Add Comment
Please, Sign In to add comment