From 9d13a1b4cffb617164b713583cb3c811aaeb9a02 Mon Sep 17 00:00:00 2001 From: Chen Date: Sun, 20 Nov 2016 17:41:59 -0500 Subject: [PATCH 1/2] Toggle between upper and lower case by double tapping screen --- Swift/VInput Keyboard/InputMode.swift | 30 +++++++++++++++++++++----- Swift/VInput Keyboard/VisualUtil.swift | 4 +++- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/Swift/VInput Keyboard/InputMode.swift b/Swift/VInput Keyboard/InputMode.swift index c65029b..e188a30 100644 --- a/Swift/VInput Keyboard/InputMode.swift +++ b/Swift/VInput Keyboard/InputMode.swift @@ -17,6 +17,7 @@ class InputMode : Mode { var keyboardController: KeyboardViewController! let MODE_NAME = "InputMode" var currentWord: String = "" + var capsOn: Bool = false init(values: Values, keyboardController: KeyboardViewController) { self.values = values @@ -53,14 +54,23 @@ class InputMode : Mode { func onSwipeUp() { // TO DO - let text = "Inserting " + values.getCurrentValue() + var text = "Inserting " + values.getCurrentValue() + //SpeechUtil.speak(textToSpeak: text) + if capsOn { + currentWord.append(values.getCurrentValue().uppercased()) + keyboardController.textDocumentProxy.insertText(values.getCurrentValue().uppercased()) + text = "Inserting upper case " + values.getCurrentValue() + } + else{ + currentWord.append(values.getCurrentValue()) + keyboardController.textDocumentProxy.insertText(values.getCurrentValue()) + } SpeechUtil.speak(textToSpeak: text) - currentWord.append(values.getCurrentValue()) - keyboardController.textDocumentProxy.insertText(values.getCurrentValue()) values.isSearchingThenReset() VisualUtil.updateViewAndAnnounce(letter: values.getCurrentValue()) + // search for results let partialTypedWord = loadFromProxy() // Threshold for when to start "predicting" @@ -110,8 +120,18 @@ class InputMode : Mode { } func doubleTap() { - let text = "Left or right of " + values.getCurrentValue() - SpeechUtil.speak(textToSpeak: currentWord) +// let text = "Left or right of " + values.getCurrentValue() +// SpeechUtil.speak(textToSpeak: currentWord) + if capsOn { + capsOn = false + VisualUtil.updateView(letter: values.getCurrentValue()) + SpeechUtil.speak(textToSpeak: "Current letter lower cased") + } + else { + capsOn = true + VisualUtil.updateView(letter: values.getCurrentValue().uppercased()) + SpeechUtil.speak(textToSpeak: "Current letter upper cased") + } } func onHold() { diff --git a/Swift/VInput Keyboard/VisualUtil.swift b/Swift/VInput Keyboard/VisualUtil.swift index d5ea3b9..11c519c 100644 --- a/Swift/VInput Keyboard/VisualUtil.swift +++ b/Swift/VInput Keyboard/VisualUtil.swift @@ -16,5 +16,7 @@ class VisualUtil { let text = "Left or right of " + letter SpeechUtil.speak(textToSpeak: text) } - + static func updateView(letter: String) { + KeyboardViewController.letterLabel.text = letter + } } From affa33378e7d1ad698ac16fdfa342df0254e3315 Mon Sep 17 00:00:00 2001 From: Chen Date: Sun, 20 Nov 2016 20:30:07 -0500 Subject: [PATCH 2/2] Toggle upper/lower case by holding with one finger; fixed issue of onHold firing twice; view reflects case of lette to be input --- Swift/VInput Keyboard/InputMode.swift | 8 +++++--- Swift/VInput Keyboard/KeyboardViewController.swift | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Swift/VInput Keyboard/InputMode.swift b/Swift/VInput Keyboard/InputMode.swift index e188a30..9be59f5 100644 --- a/Swift/VInput Keyboard/InputMode.swift +++ b/Swift/VInput Keyboard/InputMode.swift @@ -45,11 +45,13 @@ class InputMode : Mode { func onSwipeLeft() { values.shiftLeft() VisualUtil.updateViewAndAnnounce(letter: values.getCurrentValue()) + capsOn = false } func onSwipeRight() { values.shiftRight() VisualUtil.updateViewAndAnnounce(letter: values.getCurrentValue()) + capsOn = false } func onSwipeUp() { @@ -68,7 +70,7 @@ class InputMode : Mode { SpeechUtil.speak(textToSpeak: text) values.isSearchingThenReset() VisualUtil.updateViewAndAnnounce(letter: values.getCurrentValue()) - + capsOn = false // search for results @@ -119,7 +121,7 @@ class InputMode : Mode { VisualUtil.updateViewAndAnnounce(letter: values.getCurrentValue()) } - func doubleTap() { + func onHold() { // let text = "Left or right of " + values.getCurrentValue() // SpeechUtil.speak(textToSpeak: currentWord) if capsOn { @@ -134,7 +136,7 @@ class InputMode : Mode { } } - func onHold() { + func doubleTap() { SpeechUtil.speak(textToSpeak: "Inserting space") keyboardController.textDocumentProxy.insertText(" ") currentWord = "" diff --git a/Swift/VInput Keyboard/KeyboardViewController.swift b/Swift/VInput Keyboard/KeyboardViewController.swift index 2ae80fc..5f11d24 100644 --- a/Swift/VInput Keyboard/KeyboardViewController.swift +++ b/Swift/VInput Keyboard/KeyboardViewController.swift @@ -247,8 +247,10 @@ class KeyboardViewController: UIInputViewController { } //To-do: Migrate over -> Mike - func onHold() { - currentMode.onHold() + func onHold(gestureRecognizer: UIGestureRecognizer) { + if gestureRecognizer.state == UIGestureRecognizerState.began{ + currentMode.onHold() + } // if shortHoldRecognizer.state == UIGestureRecognizerState.began { // self.textDocumentProxy.insertText(" ") // newWord = true