Reputation: 1195
I'm working on a status bar application. Currently all I have is a drop down menu that either quits the app or opens a preferences window. There is a textfield in the window that will be for a number value. While testing I noticed that when I used .orderOut to hide the window a comma would appear in my number.
No idea why this is happening or what I can do to stop it.
@IBOutlet weak var statusMenu: NSMenu!
@IBOutlet weak var prefWindow: NSWindow!
@IBOutlet weak var artSizeStepper: NSStepper!
@IBOutlet weak var artSizeTextField: NSTextField!
var artSize = 1000;
let statusItem = NSStatusBar.systemStatusBar().statusItemWithLength(-1) // NSVariableStatusItemLength
func applicationDidFinishLaunching(aNotification: NSNotification) {
let icon = NSImage(named: "statusIcon")
icon?.setTemplate(true) // best for dark mode
statusItem.image = icon
statusItem.menu = statusMenu
self.prefWindow!.orderOut(self)
}
func applicationWillTerminate(aNotification: NSNotification) {
// Insert code here to tear down your application
}
@IBAction func quitClicked(sender: NSMenuItem) {
NSApplication.sharedApplication().terminate(self)
}
@IBAction func setPrefWindowVisible(sender: NSMenuItem) {
self.prefWindow!.orderFront(self)
}
@IBAction func stepArtSize(sender: NSStepper) {
self.artSizeTextField!.setValue(2000)
}
@IBAction func textArtSize(sender: NSTextField) {
}
@IBAction func cancelPrefChange(sender: NSButton) {
self.prefWindow!.orderOut(self)
}
Upvotes: 2
Views: 674
Reputation: 10479
In your storyboard select the artSizeTextField
and remove its formatter.
Upvotes: 1