I’m a junior MacOS developer. In Swift 4 Cocoa I would like to have Text Field with "special" handling of the Shift key.
By default, if a letter is entered it should be uppercased BUT if the Shift key is pressed the letter should be in lower case.
Exemple:
- “a” is entered -> transformed to “A”
- Shift+”a” is entered -> transformed to “a”
- any other entry (number etc.)should be handled normally-
I was able to force to uppercase with
override func controlTextDidChange(_ obj: Notification) {
print("Text changed")
var infoDictionary:Dictionary = obj.userInfo! as Dictionary
let text:NSText = infoDictionary["NSFieldEditor"] as! NSText
text.string = text.string.uppercased()
}
However I don't know how to "force" to lower case when the shift key is pressed.
I am very grateful for your reading and...help.