Created
January 24, 2012 09:30
-
-
Save seanlilmateus/1669249 to your computer and use it in GitHub Desktop.
putting data to a NSComboBox manually in Macruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/macruby | |
framework 'Cocoa' | |
class TestDelegate | |
attr_accessor :window | |
def applicationDidFinishLaunching(notification) | |
@window.delegate = self | |
# set the content view size and Position | |
combo_box_rect = NSMakeRect(165, 150, 170, 25) | |
# initialize the combobox | |
combo_box = NSComboBox.alloc.initWithFrame(combo_box_rect) | |
# fill the combo box (if you have a combobox connect via Interface Builder, this line & probably the next) | |
combo_box.addItemsWithObjectValues(%W(one two three four five six seven)) | |
# select on start the first element | |
combo_box.selectItemAtIndex(0) | |
# add to the content view | |
@window.contentView.addSubview(combo_box) | |
@window.center | |
end | |
def windowWillClose(sender); exit(1); end | |
end | |
# Create the Application | |
application = NSApplication.sharedApplication | |
application.delegate = TestDelegate.new | |
# create the Application Window | |
frame = [0.0, 0.0, 500, 300] | |
window = NSWindow.alloc.initWithContentRect frame, | |
styleMask: NSTitledWindowMask | NSClosableWindowMask, | |
backing: NSBackingStoreBuffered, | |
defer: false | |
window.display | |
window.makeKeyAndOrderFront(true) | |
application.delegate.window = window | |
application.run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment