Last active
August 29, 2015 14:15
-
-
Save hk0i/60ce6480f351566c31b4 to your computer and use it in GitHub Desktop.
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
class WhatAreYouDoingWindowController: NSWindowController, | |
NSWindowDelegate, NSTextFieldDelegate { | |
let tvInput: NSTextField? | |
let lblInstruction: Label? | |
override init() { | |
super.init() | |
self.window = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 400, height: 32), | |
styleMask: NSTitledWindowMask | |
| NSClosableWindowMask | |
| NSMiniaturizableWindowMask, | |
backing: .Buffered, | |
defer: false) | |
self.window!.center() | |
self.window!.title = "What are you doing?!" | |
self.window!.makeKeyAndOrderFront(nil) | |
self.window!.level = ALWAYS_ON_TOP | |
self.tvInput = NSTextField(frame: NSRect(x: 5, y: 5, width: 390, height: 22)) | |
tvInput!.editable = true | |
tvInput!.stringValue = "what are you doing?" | |
tvInput!.delegate = self | |
self.window!.contentView.addSubview(tvInput!) | |
self.window!.makeFirstResponder(tvInput!) | |
self.window!.makeKeyAndOrderFront(tvInput!) | |
} | |
override init(window: NSWindow?) { | |
super.init(window: window) | |
} | |
required init?(coder: NSCoder) { | |
super.init(coder: coder) | |
} | |
func windowWillClose(notification: NSNotification?) { | |
println("Window will close") | |
NSApplication.sharedApplication().terminate(0) | |
} | |
func textDidEndEditing(_aNotification: NSNotification) { | |
// println("Holla!") | |
// println("Holla!, \(self.tvInput!.stringValue)") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment