framework 'Cocoa'
NSApplication.sharedApplication
class Window
attr_accessor :frame, :text_frame, :window, :text_field
def initialize
@frame = NSRect.new(NSPoint.new(0, 0), NSSize.new(450, 140))
@window = NSWindow.alloc.initWithContentRect @frame,
styleMask:(NSTitledWindowMask + NSClosableWindowMask + NSMiniaturizableWindowMask),
backing:NSBackingStoreBuffered,
defer:false
@text_frame = NSRect.new(NSPoint.new(40, 90), NSSize.new(400, 18))
@text_field = NSTextField.alloc.initWithFrame @text_frame
@text_field.setBezeled false
@text_field.setStringValue "Yay for MacRuby!!!"
@text_field.setBackgroundColor NSColor.windowBackgroundColor
@text_field.setEditable false
@text_field.setSelectable false
@window.contentView.addSubview @text_field
@window.center
@window.setLevel NSFloatingWindowLevel
@window.makeKeyAndOrderFront nil
end
def setDelegate delegate
@window.setDelegate delegate
end
end
class WindowDelegate < Object
def app
NSApplication.sharedApplication
end
def windowWillClose id
app.terminate 0
end
end
window = Window.new
window.setDelegate WindowDelegate.alloc.init
This looks simple enough that I'll have to make time to play further - perhaps during my pre-RailsConf coding bash in August.