Ind.ie is now Small Technology Foundation.
Commit 21299dc9 authored by Aral Balkan's avatar Aral Balkan

Updated the delay function to add option to return on same stack frame. Setup...

Updated the delay function to add option to return on same stack frame. Setup process now intelligently decides whether to give VoiceOver time to read state transition messages by delaying the visual state transition.
parent 5328402b
......@@ -35,9 +35,16 @@ func delay(delay:Double, closure:()->())
{
//
// Run the passed closure after a given number of seconds.
// Based on: http://stackoverflow.com/questions/24034544/dispatch-after-gcd-in-swift
//
// Courtesy: http://stackoverflow.com/questions/24034544/dispatch-after-gcd-in-swift
//
if delay < 0.0 {
// Special case. If delay is negative, run the closure on the same stack frame.
// If you want to run the closure on the next stack frame, pass 0.0.
closure()
return
}
dispatch_after(
dispatch_time(
DISPATCH_TIME_NOW,
......
......@@ -213,12 +213,16 @@ class SetupViewController: NSViewController, SetupDelegate {
prepareInterfaceForChangeToStep(self.currentStep)
// Accessibility — update user on what is happening.
makeAccessibilityAnnouncement(NSLocalizedString("Handle accepted. Transitioning to second step of the setup process.", comment:"VoiceOver screen transition announcement."))
// Delay to allow voiceover a chance to read the transition
// TODO: Detect voiceover and only introduce delay if it exists.
delay(2.5)
// Decide whether to delay to allow voiceover a chance to read the transition
let voiceOverIsRunning:Bool = NSAccessibilityIsVoiceOverRunning()
let delayDuration = voiceOverIsRunning ? 2.5 : -1.0
if (voiceOverIsRunning)
{
// Accessibility — update user on what is happening.
makeAccessibilityAnnouncement(NSLocalizedString("Handle accepted. Transitioning to second step of the setup process.", comment:"VoiceOver screen transition announcement."))
}
delay(delayDuration)
{
// Get any data the current view controller may want to pass to the next one.
var dataFromCurrentStep:AnyObject? = currentViewController.dataToPassToNextStep()
......@@ -258,12 +262,17 @@ class SetupViewController: NSViewController, SetupDelegate {
self.currentStep--
prepareInterfaceForChangeToStep(self.currentStep)
// Accesibility
makeAccessibilityAnnouncement(NSLocalizedString("Returning to first step of the setup process: select handle.", comment:"VoiceOver screen transition announcement."))
// Delay to allow voiceover a chance to read the transition
// TODO: Detect voiceover and only introduce delay if it exists.
delay(1.5)
// Decide whether to delay to allow voiceover a chance to read the transition
let voiceOverIsRunning:Bool = NSAccessibilityIsVoiceOverRunning()
let delayDuration = voiceOverIsRunning ? 2.5 : -1.0
if (voiceOverIsRunning)
{
// Accesibility
makeAccessibilityAnnouncement(NSLocalizedString("Returning to first step of the setup process: select handle.", comment:"VoiceOver screen transition announcement."))
}
delay(delayDuration)
{
let nextViewController:SetupStepViewController = self.viewControllers[self.currentStep-1]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment