Package net.rim.device.api.ui.accessibility

Examples of net.rim.device.api.ui.accessibility.AccessibleText


            String dateFieldLabel = context.getAccessibleName();
            if (dateFieldLabel == null) {
                dateFieldLabel = "";
            }

            final AccessibleText text = context.getAccessibleText();
            if (Util.hasTransitionedToState(oldValue, newValue,
                    AccessibleState.FOCUSED)) {
                Util.speak("Date field " + dateFieldLabel + " focused");
            } else if (Util.hasTransitionedToState(oldValue, newValue,
                    AccessibleState.EXPANDED)) {
                Util.speak("Date field " + dateFieldLabel + " expanded");
            } else if (Util.hasTransitionedFromState(oldValue, newValue,
                    AccessibleState.EXPANDED)) {
                Util.speak("Date field " + dateFieldLabel + " collapsed");
            }

            if (text != null) {
                Util.speak("Current value " + text.getWholeText());
            }
        }
    }
View Full Code Here


        String name = context.getAccessibleName();
        if (name == null) {
            name = "";
        }

        final AccessibleText aText = context.getAccessibleText();
        switch (event) {
        case AccessibleContext.ACCESSIBLE_STATE_CHANGED:
            if (Util.hasTransitionedToState(_oldValue, _newValue,
                    AccessibleState.FOCUSED)) {
                final boolean editable =
                        (_newValue & AccessibleState.EDITABLE) != 0;
                final boolean selectable =
                        (_newValue & AccessibleState.SELECTABLE) != 0;
                final String editableString = editable ? " editable" : "";
                String value;
                if (selectable) {
                    value =
                            aText != null ? aText.getAtIndex(
                                    AccessibleText.LINE, aText
                                            .getCaretPosition()) : null;
                } else {
                    value = aText.getWholeText();
                }
                Util.speak(name + " focused " + editableString);
                if (value != null) {
                    Util.speak(name + " text " + value);
                }
            } else if (Util.hasTransitionedToState(_oldValue, _newValue,
                    AccessibleState.SELECTED)) {
                Util.speak("text field " + name + " enable selecting mode");
            } else if (Util.hasTransitionedFromState(_oldValue, _newValue,
                    AccessibleState.SELECTED)) {
                Util.speak("text field " + name + " disable selecting mode");
            } else if (Util.hasTransitionedToState(_oldValue, _newValue,
                    AccessibleState.MOUSE_OVER)) {
                Util.speak("mouse over text field " + name);
            }
            break;

        case AccessibleContext.ACCESSIBLE_TEXT_CHANGED:
            handleTextChanged((String) oldValue, (String) newValue, context);
            break;

        case AccessibleContext.ACCESSIBLE_CARET_CHANGED:
            final String oldLine =
                    aText.getAtIndex(AccessibleText.LINE, _oldValue + 1);
            if (Math.abs(_oldValue - _newValue) == 1 && oldLine.length() != 0) {
                // Sample handling indicates horizontal scroll occurred - says
                // the char.
                Util.speak(aText.getAtIndex(AccessibleText.CHAR, aText
                        .getCaretPosition()));
            } else {
                // Sample handling indicates vertical scroll occurred - says the
                // line.
                Util.speak(aText.getAtIndex(AccessibleText.LINE, ++_newValue));
            }
            break;
        }
    }
View Full Code Here

     * @param context
     *            Field on which event occured
     */
    private static void handleTextChanged(final String oldValue,
            final String newValue, final AccessibleContext context) {
        final AccessibleText aText = context.getAccessibleText();
        if (aText != null) {
            if (oldValue == null && newValue != null) {
                System.out.println("Text: Insert: " + newValue);
                System.out.println("Word At: "
                        + aText.getAtIndex(AccessibleText.WORD, aText
                                .getCaretPosition()));
            } else if (oldValue != null && newValue == null) {
                System.out.println("Text: Delete: " + oldValue);
            } else if (oldValue != null && newValue != null) {
                System.out.println("Text: Replace: " + oldValue + " with "
View Full Code Here

        // Evaluate the navagational orientation state(s) set for the accessible
        // element
        final String orientation = Util.getOrientation(statesSet);

        final AccessibleText text = context.getAccessibleText();

        final int childCount = context.getAccessibleChildCount();

        // In cases where there are many components on a
        // screen/dialog/menu...most of
        // which are not frequently used, it's more practical to set a limit on
        // the
        // number of components to be read:
        // int maxCount = Math.min( childCount, 10);
        // and then use maxCount instead of childCount.

        switch (context.getAccessibleRole()) {
        case AccessibleRole.SCREEN:
            if (busy) {
                Util.speak("Screen " + name + " loading");
            } else {
                Util.speak("Screen " + name);
                for (int i = 0; i < childCount; i++) {
                    final AccessibleContext child =
                            context.getAccessibleChildAt(i);
                    readChildElement(child);
                }
            }
            break;

        case AccessibleRole.TEXT_FIELD:
            if (text != null) {
                String currentText = text.getWholeText();
                currentText = currentText != null ? currentText.trim() : "";
                final String textToSpeak =
                        currentText.length() > 0 ? " with text " + currentText
                                : " empty";
                toSpeak.append(name + " text field " + textToSpeak);
                toSpeak.append(focusedText);
                toSpeak.append(editableText);
            }
            break;

        case AccessibleRole.LABEL:
            toSpeak.append(name);
            toSpeak.append(focusableText);
            toSpeak.append(focusedText);
            toSpeak.append(selectedText);
            toSpeak.append(expandedText);
            break;

        case AccessibleRole.APP_ICON:
            toSpeak.append(name + "application icon");
            toSpeak.append(focusedText);
            break;

        case AccessibleRole.ICON:
            toSpeak.append(name + " icon ");
            toSpeak.append(focusedText);
            break;

        case AccessibleRole.DATE:
            toSpeak.append(name + " date field ");
            toSpeak.append(selectedText);
            if (text != null) {
                toSpeak.append(" with current value " + text.getWholeText());
            }
            break;

        case AccessibleRole.LIST:
            if (busy) {
View Full Code Here

TOP

Related Classes of net.rim.device.api.ui.accessibility.AccessibleText

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.