Gets the name of the specified object.
| 1127 | |
| 1128 | // Gets the name of the specified object. |
| 1129 | wxAccStatus NumericTextCtrlAx::GetName(int childId, wxString *name) |
| 1130 | { |
| 1131 | if (!mCtrl->mFormatter) |
| 1132 | return wxACC_FAIL; |
| 1133 | |
| 1134 | // Slightly messy trick to save us some prefixing. |
| 1135 | auto & mFields = mCtrl->mFormatter->GetFields(); |
| 1136 | auto & mDigits = mCtrl->mFormatter->GetDigitInfos(); |
| 1137 | auto & mFieldValueStrings = mCtrl->mFieldValueStrings; |
| 1138 | |
| 1139 | wxString ctrlString = mCtrl->GetString(); |
| 1140 | int field = mDigits[mCtrl->GetFocusedDigit()].field + 1; |
| 1141 | // In bar formats, the size of the first field can automatically |
| 1142 | // increase. So use the position of the focused digit from |
| 1143 | // the end, rather than the start, to determine whether |
| 1144 | // the focus has changed. See issue #5344. |
| 1145 | int childIdFromEnd = mCtrl->mBoxes.size() - childId + 1; |
| 1146 | |
| 1147 | // Return the entire string including the control label |
| 1148 | // when the requested child ID is wxACC_SELF. (Mainly when |
| 1149 | // the control gets the focus.) |
| 1150 | if ((childId == wxACC_SELF) || |
| 1151 | // We subtract 1 from childId in the other cases below, and |
| 1152 | // need to avoid neg index to mDigits, so funnel into this clause. |
| 1153 | (childId < 1)) |
| 1154 | { |
| 1155 | *name = mCtrl->GetName(); |
| 1156 | if (name->empty()) { |
| 1157 | *name = mCtrl->GetLabel(); |
| 1158 | } |
| 1159 | |
| 1160 | *name += wxT(" ") + |
| 1161 | mCtrl->GetString(); |
| 1162 | } |
| 1163 | // This case is needed because of the behaviour of Narrator, which |
| 1164 | // is different for the other Windows screen readers. After a focus event, |
| 1165 | // Narrator causes getName() to be called more than once. However, the code in |
| 1166 | // the following else statement assumes that it is executed only once |
| 1167 | // when the focus has been moved to another digit. This else if statement |
| 1168 | // ensures that this is the case, by using a cached value if nothing |
| 1169 | // has changed. |
| 1170 | else if (childIdFromEnd == mLastDigit && ctrlString.IsSameAs(mLastCtrlString)) { |
| 1171 | *name = mCachedName; |
| 1172 | } |
| 1173 | else { |
| 1174 | // The user has moved from one field of the time to another so |
| 1175 | // report the value of the field and the field's label. |
| 1176 | if (mLastField != field) { |
| 1177 | wxString label = mFields[field - 1].label; |
| 1178 | int cnt = mFields.size(); |
| 1179 | wxString decimal = wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER); |
| 1180 | |
| 1181 | // If the NEW field is the last field, then check it to see if |
| 1182 | // it represents fractions of a second. |
| 1183 | // PRL: click a digit of the control and use left and right arrow keys |
| 1184 | // to exercise this code |
| 1185 | |
| 1186 | if (field > 1 && field == cnt) { |