I have an NSTextField
with an NSNumberFormatter
to limit entry to numbers, but it will not allow me to type a hyphen to enter a negative number (even after setting "minimum" to "-1,000").
I can copy/paste a "-1" into the field and programmatically set its value, but users can't enter hyphens.
Is there a way to allow this?
Thanks.
PS, here's the custom formatter I tried (without success) as per Nishant's suggestion below:
import Cocoa
class CustomNumberFormatter: NSNumberFormatter {
override func isPartialStringValid(partialStringPtr: AutoreleasingUnsafeMutablePointer<NSString?>,
proposedSelectedRange proposedSelRangePtr: NSRangePointer, originalString origString: String,
originalSelectedRange origSelRange: NSRange, errorDescription error: AutoreleasingUnsafeMutablePointer<NSString?>) -> Bool {
return true
}
}