CustomA11yObject

Since: BlackBerry 10.2.0

#include <bb/cascades/CustomA11yObject>

Accessibility object that can be used to implement custom accessibility behavior.

CustomA11yObject exposes an accessibility API similar to the ones defined by WAI-ARIA. It can be used to make custom controls accessible, or make compositions of built-in controls behave in a custom way (from an accessibility point of view).

Contrary to the base class AbstractA11yObject, on a CustomA11yObject you can set the role. Each role defines a set of specialization contracts that the accessibility object is expected to support.

CustomA11yObject is expected to represent the state of the accessible control using state property.

Typically most controls will implement at least ComponentA11ySpecialization by responding to activation requests sent by the ComponentA11ySpecialization::activate() signal, and optionally support highlighting by responding to the ComponentA11ySpecialization::highlighted() signal.

Some controls may implement other specializations matching their roles.

For example, if a control's role is set to A11yRole::Slider, the framework expects that accessibility object to support ValueA11ySpecialization, which allows assistive technology to extract minimum, maximum and current values from the control, as well as change the value.

QML usage:
    Container {

        Label {
            id: label0
            text: "This Slider Slides!"
            accessibility {
                name: "Slider"
                description: "We should slide"
            }
        }

        Slider {
            id: slider
            fromValue: 0
            value: 50
            toValue: 100

            accessibility {
                labelledBy: label0
            }
        }

        Label {
            text: "Slider: " + value0.text
        }

        accessibility: CustomA11yObject {
            id: accessibility0

            role: A11yRole.Slider
            name: "Awesome slider"
            description: "Item describing whether to slide stuff, tap to reset"

            ComponentA11ySpecialization {
                id: component0
                onActivationRequested: {
                    if (event.type == A11yComponentActivationType.Tap) {
                        slider.value = undefined
                        event.consume()
                    }
                }
            }
            ValueA11ySpecialization {
                id: value0

                minValue: slider.fromValue
                value: slider.immediateValue
                maxValue: slider.toValue

                valueText: "min: " + minValue.toPrecision(3) + " value: " + value.toPrecision(3) + " max: " + maxValue.toPrecision(3)

                onValueAdjustmentRequested: {
                    switch (adjustmentType) {
                    case A11yValueAdjustmentType.SingleStepAdd: slider.value *= 1.05; break;
                    case A11yValueAdjustmentType.SingleStepSubtract: slider.value *= 0.95; break;
                    }
                }
                onValueSetRequested: {
                    slider.value = value;
                }
            }

        }
    }

    Container {

        Label {
            id: label
            text: "Buy stuff?"
            accessibility {
                name: "Buy Stuff"
                description: "should we buy stuff checkbox"
            }
        }

        CheckBox {
            id: checkbox
            accessibility {
                labelledBy: label
            }
        }

        Label {
            id: label1
            text: "CAO checked: " + accessibility.state.checked
        }

        accessibility: CustomA11yObject {
            id: accessibility

            role: A11yRole.Button
            name: "stuffs"
            description: "Item describing whether to buy stuff, tap to activate"

            state {
                checkable: true
                checked: checkbox.checked
            }

            ComponentA11ySpecialization {
                id: component
                onActivationRequested: {
                    if (activationType == A11yComponentActivationType.Tap) {
                        checkbox.checked != checkbox.checked
                    }
                }
            }
        }
    }


Overview

QML properties

extendedRole: QString
role: bb::cascades::A11yRole::Type
specializations: QDeclarativeListProperty< bb::cascades::AbstractA11ySpecialization > [read-only]
state: bb::cascades::A11yStateHolder [read-only]
attachedObjects: QDeclarativeListProperty< QObject > [read-only]Inherited
description: QStringInherited
labelledBy: QDeclarativeListProperty< bb::cascades::UIObject > [read-only]Inherited
name: QStringInherited
objectName: QStringInherited
parent: QObject [read-only]Inherited
ui: bb::cascades::UIConfig [read-only]Inherited

Properties Index

Public Functions Index

CustomA11yObject (UIObject *parent=0)
CustomA11yObject (bb::cascades::A11yRole::Type role, UIObject *parent=0)
CustomA11yObject (const QString &extendedRole, UIObject *parent=0)
virtual ~CustomA11yObject ()
Q_INVOKABLE voidaddSpecialization (bb::cascades::AbstractA11ySpecialization *specialization)
QStringextendedRole () const
voidremoveAllSpecializations ()
Q_INVOKABLE boolremoveSpecialization (bb::cascades::AbstractA11ySpecialization *specialization)
bb::cascades::AbstractA11ySpecialization *specializationAt (int index) const
intspecializationCount () const
bb::cascades::A11yStateHolder *state () const
Q_INVOKABLE voidaddLabel (bb::cascades::UIObject *label)Inherited
QStringdescription () const Inherited
virtual boolevent (QEvent *event)Inherited
Q_INVOKABLE intindexOfLabel (bb::cascades::UIObject *label) const Inherited
Q_INVOKABLE bb::cascades::UIObject *labelAt (int index) const Inherited
Q_INVOKABLE intlabelCount () const Inherited
QStringname () const Inherited
Q_INVOKABLE voidremoveAllLabels ()Inherited
Q_INVOKABLE voidremoveLabel (bb::cascades::UIObject *label)Inherited
Q_SLOT voidresetDescription ()Inherited
Q_SLOT voidresetName ()Inherited
bb::cascades::A11yRole::Typerole () const Inherited
Q_SLOT voidsetDescription (const QString &description)Inherited
Q_SLOT voidsetName (const QString &name)Inherited
voidsetObjectName (const QString &name)Inherited
virtual Q_INVOKABLE QStringtoDebugString () const Inherited
Q_INVOKABLE bb::cascades::UIConfig *ui () const Inherited

Protected Functions Index

Only has inherited protected functions

BaseObject (QObject *parent=0)Inherited
virtual voidconnectNotify (const char *signal)Inherited
virtual voiddisconnectNotify (const char *signal)Inherited

Signals Index

voidspecializationAdded (bb::cascades::AbstractA11ySpecialization *specialization)
voidspecializationRemoved (bb::cascades::AbstractA11ySpecialization *specialization)
voidcreationCompleted ()Inherited
voiddescriptionChanged (const QString &description)Inherited
voidlabelAdded (bb::cascades::UIObject *label)Inherited
voidlabelRemoved (bb::cascades::UIObject *label)Inherited
voidnameChanged (const QString &name)Inherited
voidobjectNameChanged (const QString &objectName)Inherited

Properties

QString extendedRole

The extended role of an accessible control.

Since:

BlackBerry 10.3.0

bb::cascades::A11yRole::Type role

The role of an accessible control.

Describes the role of an accessible control, e.g. "Button", "Check box", "Text" etc. This is a init-time only property, once initialized during object creation the role cannot be changed.

The default value for this property is bb::cascades::A11yRole::Undefined.

Since:

BlackBerry 10.2.0

QDeclarativeListProperty< bb::cascades::AbstractA11ySpecialization > specializations[read-only]

A QDeclarativeListProperty object that contains the list of specializations supported by this accessibility object.

Note:

You are only allowed to add one specialization object per type. If more than one specialization object of the same type is added, only the first specialization object is used, the rest are ignored.

QML usage:
        accessibility: CustomA11yObject {
            id: accessibility0

            role: A11yRole.Slider
            name: "Awesome slider"
            description: "Item describing whether to slide stuff, tap to reset"

            ComponentA11ySpecialization {
                id: component0
                onActivationRequested: {
                    if (event.type == A11yComponentActivationType.Tap) {
                        slider.value = undefined
                        event.consume()
                    }
                }
            }
            ValueA11ySpecialization {
                id: value0

                minValue: slider.fromValue
                value: slider.immediateValue
                maxValue: slider.toValue

                valueText: "min: " + minValue.toPrecision(3) + " value: " + value.toPrecision(3) + " max: " + maxValue.toPrecision(3)

                onValueAdjustmentRequested: {
                    switch (adjustmentType) {
                    case A11yValueAdjustmentType.SingleStepAdd: slider.value *= 1.05; break;
                    case A11yValueAdjustmentType.SingleStepSubtract: slider.value *= 0.95; break;
                    }
                }
                onValueSetRequested: {
                    slider.value = value;
                }
            }

        }
Since:

BlackBerry 10.2.0

bb::cascades::A11yStateHolder state[read-only]

The state of an accessible control.

Describes the state of an accessible control, e.g. Disabled, Busy, Checked etc.

QML usage:
        accessibility: CustomA11yObject {
            id: accessibility

            role: A11yRole.Button
            name: "stuffs"
            description: "Item describing whether to buy stuff, tap to activate"

            state {
                checkable: true
                checked: checkbox.checked
            }

            ComponentA11ySpecialization {
                id: component
                onActivationRequested: {
                    if (activationType == A11yComponentActivationType.Tap) {
                        checkbox.checked != checkbox.checked
                    }
                }
            }
        }
Since:

BlackBerry 10.2.0

QDeclarativeListProperty< QObject > attachedObjectsInherited[read-only]

A hierarchical list of the UIObject's attached objects.

Since:

BlackBerry 10.0.0

QString descriptionInherited

The human-readable description for an accessible control.

See also:

bb::cascades::Control::accessibility

Since:

BlackBerry 10.2.0

QDeclarativeListProperty< bb::cascades::UIObject > labelledByInherited[read-only]

A QDeclarativeListProperty that contains all objects that act as labels for the accessible control.

An accessible control can use other objects as "labels" for description, in addition to the name and description properties. An example of usage could be a text field that is described by a label. Multiple labels can be assigned, if multiple objects provide information of different levels of detail.

If a label is added, the name and description from the label object's accessibility object, or built in defaults, is used. A Label control rarely needs a name set in order to act as label for another control, since by default the text on the label is used as name.

Note:

The objects acting as labels must be of type Control, AbstractPane or AbstractDialog, otherwise the label object will be disregarded.

Since:

BlackBerry 10.2.0

QString nameInherited

The human-readable name for an accessible control.

Every accessible control should have human-readable text associated with it. In most cases, this can be inferred by the text being displayed on the object or the text of a label that is labeling the object. In some cases, such as with icon-only push buttons, the name cannot be inferred and must be supplied by the application developer. This property represents that string.

Note:

Setting this property will override the default name inference of the control.

The default value for this property is QString::Null, indicating that no name is set.
Since:

BlackBerry 10.2.0

QString objectNameInherited

This property is overridden from QObject.

See also:

QObject::objectName().

Since:

BlackBerry 10.0.0

QObject parentInherited[read-only]

A read-only property that represents this object's parent.

The parent of an object is specified using QObject::setParent(QObject*). The purpose of the property is to expose the object's parent to QML.

This property is read-only to prevent modifications from QML, where typically the parent is declaratively set. In C++ code, the parent can be explicitly set using QObject::setParent(QObject*), or implicitly set by adding it to a visual container.

The default value of this property is 0.

Since:

BlackBerry 10.0.0

bb::cascades::UIConfig uiInherited[read-only]

An object that gives access to unit conversion routines.

QML use:
        // Size using design units
        Container {
            preferredWidth: ui.du(12)
            preferredHeight: ui.du(5)
        }

        // Size using design units, snap to whole pixels
        Container {
            preferredWidth: ui.sdu(13.5)
            preferredHeight: ui.sdu(7.5)
        }

        // Size using absolute pixel values
        Container {
            preferredWidth: ui.px(150)
            preferredHeight: ui.px(50)
        }
C++ use:
Container *container1 = Container::create().background(Color::Red);
UIConfig *ui = container1->ui();
container1->setPreferredWidth(ui->du(12));
container1->setPreferredHeight(ui->du(5));

Container *container2 = Container::create().background(Color::Green);
container2->setPreferredWidth(ui->sdu(13.5));
container2->setPreferredHeight(ui->sdu(7.5));

Container *container3 = Container::create().background(Color::Blue);
container3->setPreferredWidth(ui->px(150));
container3->setPreferredHeight(ui->sdu(50));
Since:

Blackberry 10.3.0

Public Functions

CustomA11yObject (

Creates a CustomA11yObject with role bb::cascades::A11yRole::Undefined.

Parameters
parent

The parent object, or 0. This parameter is optional. The default is 0 if you do not specify a parent.

Since:

BlackBerry 10.2.0

CustomA11yObject (

Creates a CustomA11yObject with the supplied role.

Parameters
role

The role that the accessibility object should assume.

parent

The parent object, or 0. This parameter is optional. The default is 0 if you do not specify a parent.

Since:

BlackBerry 10.2.0

CustomA11yObject (

Creates a CustomA11yObject with the supplied extended role.

role will be set to A11yRole::Extended.

Parameters
extendedRole

The name of the extended role that the accessibility object should assume.

parent

The parent object, or 0. This parameter is optional. The default is 0 if you do not specify a parent.

Since:

BlackBerry 10.3.0

virtual~CustomA11yObject ()

Destructor.

Since:

BlackBerry 10.2.0

Q_INVOKABLE void addSpecialization (

Adds an AbstractA11ySpecialization to the accessibility object.

The accessibility object takes ownership of the AbstractA11ySpecialization object, since AbstractA11ySpecialization objects should not typically be shared. If the AbstractA11ySpecialization is 0 or it already belongs to the accessibility object, the specialization set is not added. Once completed, the specializationAdded() signal is emitted.

Note:

You are only allowed to add one specialization object per type. If more than one specialization object of the same type is added, only the first specialization object is used, the rest are ignored.

Parameters
specialization

The AbstractA11ySpecialization to add to the CustomA11yObject

Since:

BlackBerry 10.2.0

QString extendedRole ()

Retrieves the value of the extendedRole property.

Return:

The name of the extended role the accessible object assumes.

Since:

BlackBerry 10.3.0

void removeAllSpecializations ()

Removes all AbstractA11ySpecialization objects from the accessibility object and deletes them.

Once completed, the specializationRemoved() signal is emitted with 0 as its parameter.

Since:

BlackBerry 10.2.0

Q_INVOKABLE bool removeSpecialization (

Removes an AbstractA11ySpecialization from the accessibility object.

Once the AbstractA11ySpecialization is removed, the accessibility object no longer references it, but it is still owned by the accessibility object. It is up to the application to either delete the removed AbstractA11ySpecialization, transfer its ownership (by setting its parent) to another object or leave it as a child of the accessibility object (in which case it will be deleted with the accessibility object).

Once completed, the specializationRemoved() signal is emitted.

Parameters
specialization

The specialization to remove.

Return:

true if the AbstractA11ySpecialization was owned by the CustomA11yObject, and false otherwise.

Since:

BlackBerry 10.2.0

bb::cascades::AbstractA11ySpecialization * specializationAt (
  • intindex)

Retrieves an AbstractA11ySpecialization at a specified index.

Ownership of the AbstractA11ySpecialization object remains with the accessibility object.

Parameters
index

The index of the AbstractA11ySpecialization.

Return:

The requested AbstractA11ySpecialization if the index was valid, and 0 otherwise.

Since:

BlackBerry 10.2.0

int specializationCount ()

Retrieves the number of AbstractA11ySpecialization objects.

Return:

The number of AbstractA11ySpecialization objects.

Since:

BlackBerry 10.2.0

bb::cascades::A11yStateHolder * state ()

Retrieves the accessibility state of the control.

Return:

The accessibility state of the control.

Since:

BlackBerry 10.2.0

Q_INVOKABLE void addLabel (Inherited

Adds a label to the labelledBy property of the accessible control.

New labels are added as the last item in the list. The object that is passed must not be 0 or it will be ignored.

Ownership of the label object does not change. Since the object used as label is typically part of the UI tree, it retains its parent. The AbstractA11yObject will only become parent if explicitly set.

Parameters
label

The object to be added as label; must be a Control and not 0.

Since:

BlackBerry 10.2.0

QString description ()Inherited

Returns the accessibility description of the control.

Return:

The accessibility description of the control.

Since:

BlackBerry 10.2.0

virtual bool event (Inherited

Overloaded to implement the event mechanism in Cascades.

Warning!

If this function is overridden, it must be called by the derived class for events to work properly in Cascades.

Parameters
event

The received event.

Return:

True if the received event was recognized and processed, false otherwise.

Since:

BlackBerry 10.0.0

Q_INVOKABLE int indexOfLabel (Inherited

Returns the index of a label object in the labelledBy property.

If the object isn't among the labels or if the object is 0, -1 is returned.

Parameters
label

The label object to get the index from.

Return:

The index of the specified label object if the object is valid, -1 otherwise.

Since:

BlackBerry 10.2.0

Q_INVOKABLE bb::cascades::UIObject * labelAt (
  • intindex)
Inherited

Returns the label object at the specified index in the labelledBy property.

Parameters
index

The index of the object.

Return:

The requested object if the index was valid, 0 otherwise.

Since:

BlackBerry 10.2.0

Q_INVOKABLE int labelCount ()Inherited

Returns the number of labels in the labelledBy property of the accessible control.

Return:

The number of labels.

Since:

BlackBerry 10.2.0

QString name ()Inherited

Returns the accessibility name of the control.

Return:

The accessibility name of the control.

Since:

BlackBerry 10.2.0

Q_INVOKABLE void removeAllLabels ()Inherited

Removes all labels from the labelledBy property of the accessible control.

Emits labelRemoved with 0 as argument. Removed label objects that have the AbstractA11yObject as parent will be destroyed, before the signal is emitted.

Since:

BlackBerry 10.2.0

Q_INVOKABLE void removeLabel (Inherited

Removes a label from the labelledBy property of the accessible control.

If the label is found, labelRemoved will be emitted. If the removed label object has the AbstractA11yObject as parent, it will be destroyed after the signal has been emitted.

Parameters
label

The object to be removed; must not be 0.

Since:

BlackBerry 10.2.0

Q_SLOT void resetDescription ()Inherited

Resets the accessibility description of the control to QString::Null.

Since:

BlackBerry 10.2.0

Q_SLOT void resetName ()Inherited

Resets the accessibility name of the control to QString::Null.

Since:

BlackBerry 10.2.0

bb::cascades::A11yRole::Type role ()Inherited

Returns the accessibility role of the control.

Return:

The accessibility role of the control.

Since:

BlackBerry 10.2.0

Q_SLOT void setDescription (Inherited

Sets the accessibility description of the control.

Since:

BlackBerry 10.2.0

Q_SLOT void setName (Inherited

Sets the accessibility name of the control.

Since:

BlackBerry 10.2.0

void setObjectName (Inherited

Sets the objectName property.

Parameters
name

The new name for the object.

Since:

BlackBerry 10.0.0

virtual Q_INVOKABLE QString toDebugString ()Inherited

Returns a debug string representing this object.

Return:

A debug string for the object.

Since:

BlackBerry 10.0.0

Q_INVOKABLE bb::cascades::UIConfig * ui ()Inherited

Returns the UIConfig for this ui object.

The UIConfig can be used to perform unit conversions from design units (du) and snapped design units (sdu) to pixels.

Ownership remains with Cascades.

C++ use:
Container *container1 = Container::create().background(Color::Red);
UIConfig *ui = container1->ui();
container1->setPreferredWidth(ui->du(12));
container1->setPreferredHeight(ui->du(5));

Container *container2 = Container::create().background(Color::Green);
container2->setPreferredWidth(ui->sdu(13.5));
container2->setPreferredHeight(ui->sdu(7.5));

Container *container3 = Container::create().background(Color::Blue);
container3->setPreferredWidth(ui->px(150));
container3->setPreferredHeight(ui->sdu(50));
Return:

The UIConfig for this ui object.

Since:

BlackBerry 10.3.0

Protected Functions

(Only has inherited protected functions)

BaseObject (Inherited

Constructs an instance of BaseObject's subclass.

Parameters
parent

An optional parent, defaults to 0.

Since:

BlackBerry 10.0.0

virtual void connectNotify (
  • const char *signal)
Inherited

Overloaded to implement the event mechanism in Cascades.

If this function is overridden, it must be called by the derived class for events to work properly in Cascades.

Parameters
signal

The connected signal.

Since:

BlackBerry 10.0.0

virtual void disconnectNotify (
  • const char *signal)
Inherited

Overloaded to implement the event mechanism in Cascades.

If this function is overridden, it must be called by the derived class for events to work properly in Cascades.

Parameters
signal

The disconnected signal.

Since:

BlackBerry 10.0.0

Signals

void specializationAdded (

Emitted when an AbstractA11ySpecialization has been added to the Control.

Parameters
specialization

The AbstractA11ySpecialization that has been added.

Since:

BlackBerry 10.2.0

void specializationRemoved (

Emitted when an AbstractA11ySpecialization has been removed from the control.

Parameters
specialization

The AbstractA11ySpecialization that has been removed. 0 if emitted by removeAllSpecializations().

Since:

BlackBerry 10.2.0

void creationCompleted ()Inherited

Emitted when this object is instantiated as a result of loading a QML document and creating the root node (only after the root component that caused this instantiation has completed construction), or when the object is being constructed from its builder class.

This signal indicates that the construction and initialization of the object has been completed, the properties are initialized, and any QML binding values have been assigned to the object.

This signal is not emitted when the object is constructed from C++ using the constructor. If the object is constructed using its builder class, the signal is emitted when the the builder class returns the fully constructed object.

This signal can be used when there is an activity that needs to be performed, such as a property state integrity verification after the object is instantiated from a QML document or a builder, but before control is returned to the application.

See also:

QmlDocument

Since:

BlackBerry 10.0.0

void descriptionChanged (Inherited

Emitted when the description property changes.

Parameters
description

The new value of description.

Since:

BlackBerry 10.2.0

void labelAdded (Inherited

Emitted when a label object has been added to the labelledBy property of the accessible control.

Parameters
label

The label object that has been added.

Since:

BlackBerry 10.2.0

void labelRemoved (Inherited

Emitted when a label object has been removed from the labelledBy property of the accessible control.

Parameters
label

The label object that has been removed. 0 if emitted by removeAllLabels().

Since:

BlackBerry 10.2.0

void nameChanged (Inherited

Emitted when the name property changes.

Parameters
name

The new value of name.

Since:

BlackBerry 10.2.0

void objectNameChanged (Inherited

This signal is emitted when the objectName property is changed.

Since:

BlackBerry 10.0.0

Last modified: 2014-06-24



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus