Objectives

The goal of this lab is to understand the following concepts:

Overview

In lab 6.4 we built a screen reader that told us what key on the keyboard was pressed. In Quorum, we can write screen readers that do even more. In this lab we will make another screen reader that will tell us when a new window, button, or any other component has gained focus.

Task 1: Getting Started

Start Sodbeans. Create a new “Quorum Application” project, and name it Lab6_5. In the Main.quorum file, it should contain a Main class and Main action.

We will need to create an additional class in this project. In the New File dialog, create a new file by selecting “Quorum” and “Quorum Class” in the Categories and File Types windows, respectively. Then, name the new file Observer in the New Quorum Class dialog.

Don't forget to include the appropriate libraries!

Task 2: Inheriting from the FocusObserver Class

Just like in Lab 6.4, our Observer class will need to inherit the variables and actions of an observer class. The class we need to include in order to get the events that involve the focus changing is the FocusObserver class. Just as in the last lab, use the is keyword to inherit from the FocusObserver class.

use Libraries.Accessibility.all 
use Libraries.Sound.Speech

class Observer is FocusObserver
end

Just as in Lab 6.4, our Observer class is going to need an instance of the Speech class to say things quickly.

We will also need to implement the blueprint action ReceiveEvent in our Observer class. In Lab 6.4 we used the GetDescription action to explain the event, but you can also get the individual aspects of the event and make your own sentence to describe the event. The FocusEvent class has quite a few actions that you can use to get individual information about the event.

Use any or all of these actions to create a description of the event and use the Speech object to say it.

action ReceiveEvent(FocusEvent event)
    speech:Say("The " + event:GetComponent() + ", " + event:GetComponentName() + ", was focused. Its keyboard shortcut is " + event:GetKeyboardShortcut() + ".")
end

Above is an example of how you could combine the parts of the event to make a sentence to describe it.

Task 3: Using the Observer class

Now that we have implemented the Observer class, we can add an instance of it to our of AccessibilityManager. You can then start the AccessibilityManager and begin listening for events just as you did in Lab 6.4.

Sample Output

When you run the program it should not do anything until you focus on something (open a new window or click a button or menu). Once you do that it should say out loud the sentence you created.

When you are done, debug and fix any errors, then show your code to your instructor.

Next Tutorial

In the next tutorial, we will discuss Assignment 6.1, which describes an introduction to using derived actions.