Skip to content

RAccessibleToolButton

Class in GUI Module
Header: #include <src/gui/RAccessibleToolButton.h>

All rights reserved.

This file is part of the QCAD project.

QCAD is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

QCAD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with QCAD. Accessibility implementation for tool buttons that represent an action (tool buttons of tool bars, of the CAD tool bar and of tool button panels).

Every tool of QCAD is an RGuiAction and every RGuiAction is checkable, since a tool button stays checked while its tool is running. Qt derives the accessible role of a button from exactly that property: a checkable button that is not auto exclusive is reported as QAccessible::CheckBox (QAccessibleButton::role()), and a check box offers the accessible actions “Toggle” and “Press”, in that order.

On macOS, both actions are mapped to AXPress by the Cocoa plugin and the first one wins, so a screen reader that presses a tool button (VoiceOver: Control+Option+Space) ends up in QAccessibleButton::doAction(“Toggle”), which calls QAbstractButton::toggle(). That sets the checked state of the button directly, bypassing QToolButton::nextCheckState() and therefore the default action of the button: the button appears checked, but the tool is never started.

The factory claims every QToolButton (not only those with a default action): Qt creates and caches the accessible interface of a tool bar button during construction, before its default action is set, so the decision has to be made on demand in the interface (role()). Tool buttons without an RGuiAction behave like Qt’s own implementation. The overflow button of a tool bar (QToolBarExtension) gets a name.

Tool buttons with a default action are therefore exposed as:

  • QAccessible::Button (not CheckBox), since starting a tool is a command and not an on/off setting. The checkable / checked state is kept, so the running tool is still reported (AXValue). Actions that really toggle something (RGuiAction::isToggleable()) keep the check box role.
  • a single “Press” action that goes through QAbstractButton::click(), i.e. through exactly the same code path as a mouse click.
static void install()
Installs the accessibility factory (once).
static bool installed

static void RAccessibleToolButton::install()

static

Installs the accessibility factory (once).

Called by RMainWindowQt.

static bool RAccessibleToolButton::installed = false

static private