|
Lines 2226-2232
Link Here
|
| 2226 |
/* Get the default keyboard shortcut from the OS. */ |
2226 |
/* Get the default keyboard shortcut from the OS. */ |
| 2227 |
code = iaccessible.get_accKeyboardShortcut(varChild, pszKeyboardShortcut); |
2227 |
code = iaccessible.get_accKeyboardShortcut(varChild, pszKeyboardShortcut); |
| 2228 |
if (code == COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID |
2228 |
if (code == COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID |
| 2229 |
if (accessibleListeners.size() == 0) return code; |
2229 |
if (accessibleListeners.size() == 0 && !(control instanceof Tree || control instanceof Table)) return code; |
| 2230 |
if (code == COM.S_OK) { |
2230 |
if (code == COM.S_OK) { |
| 2231 |
int /*long*/[] pKeyboardShortcut = new int /*long*/[1]; |
2231 |
int /*long*/[] pKeyboardShortcut = new int /*long*/[1]; |
| 2232 |
COM.MoveMemory(pKeyboardShortcut, pszKeyboardShortcut, OS.PTR_SIZEOF); |
2232 |
COM.MoveMemory(pKeyboardShortcut, pszKeyboardShortcut, OS.PTR_SIZEOF); |
|
Lines 2241-2246
Link Here
|
| 2241 |
|
2241 |
|
| 2242 |
AccessibleEvent event = new AccessibleEvent(this); |
2242 |
AccessibleEvent event = new AccessibleEvent(this); |
| 2243 |
event.childID = osToChildID(v.lVal); |
2243 |
event.childID = osToChildID(v.lVal); |
|
|
2244 |
if (osKeyboardShortcut == null && (control instanceof Tree || control instanceof Table)) { |
| 2245 |
/* |
| 2246 |
* Get the default shortcut for a Table or Tree from the preceding Label, if any. |
| 2247 |
*/ |
| 2248 |
String text = getAssociatedLabel (); |
| 2249 |
if (text != null) { |
| 2250 |
char mnemonic = _findMnemonic (text); |
| 2251 |
if (mnemonic != '\0') { |
| 2252 |
osKeyboardShortcut = "Alt+"+mnemonic; //$NON-NLS-1$ |
| 2253 |
} |
| 2254 |
} |
| 2255 |
} |
| 2244 |
event.result = osKeyboardShortcut; |
2256 |
event.result = osKeyboardShortcut; |
| 2245 |
for (int i = 0; i < accessibleListeners.size(); i++) { |
2257 |
for (int i = 0; i < accessibleListeners.size(); i++) { |
| 2246 |
AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i); |
2258 |
AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i); |
|
Lines 2272-2278
Link Here
|
| 2272 |
} |
2284 |
} |
| 2273 |
} |
2285 |
} |
| 2274 |
if (code == COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID |
2286 |
if (code == COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID |
| 2275 |
if (accessibleListeners.size() == 0) { |
2287 |
if (accessibleListeners.size() == 0 && !(control instanceof Tree || control instanceof Table)) { |
| 2276 |
if (DEBUG) print(this + ".IAccessible::get_accName(" + v.lVal + ") returning name=" + osName + " from super" + hresult(code)); |
2288 |
if (DEBUG) print(this + ".IAccessible::get_accName(" + v.lVal + ") returning name=" + osName + " from super" + hresult(code)); |
| 2277 |
return code; |
2289 |
return code; |
| 2278 |
} |
2290 |
} |
|
Lines 2280-2285
Link Here
|
| 2280 |
|
2292 |
|
| 2281 |
AccessibleEvent event = new AccessibleEvent(this); |
2293 |
AccessibleEvent event = new AccessibleEvent(this); |
| 2282 |
event.childID = osToChildID(v.lVal); |
2294 |
event.childID = osToChildID(v.lVal); |
|
|
2295 |
if (osName == null && (control instanceof Tree || control instanceof Table)) { |
| 2296 |
/* |
| 2297 |
* Get the default name for a Table or Tree from the preceding Label, if any. |
| 2298 |
*/ |
| 2299 |
String text = getAssociatedLabel (); |
| 2300 |
if (text != null) { |
| 2301 |
osName = stripMnemonic (text); |
| 2302 |
} |
| 2303 |
} |
| 2283 |
event.result = osName; |
2304 |
event.result = osName; |
| 2284 |
for (int i = 0; i < accessibleListeners.size(); i++) { |
2305 |
for (int i = 0; i < accessibleListeners.size(); i++) { |
| 2285 |
AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i); |
2306 |
AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i); |
|
Lines 2292-2297
Link Here
|
| 2292 |
return COM.S_OK; |
2313 |
return COM.S_OK; |
| 2293 |
} |
2314 |
} |
| 2294 |
|
2315 |
|
|
|
2316 |
/* |
| 2317 |
* Return the Label immediately preceding the receiver in the z-order, |
| 2318 |
* or null if none. |
| 2319 |
*/ |
| 2320 |
String getAssociatedLabel () { |
| 2321 |
Control[] siblings = control.getParent ().getChildren (); |
| 2322 |
for (int i = 0; i < siblings.length; i++) { |
| 2323 |
if (siblings [i] == control) { |
| 2324 |
if (i > 0) { |
| 2325 |
Control sibling = siblings [i-1]; |
| 2326 |
if (sibling instanceof Label) return ((Label) sibling).getText(); |
| 2327 |
// if (sibling instanceof CLabel) return ((CLabel) sibling).getText(); |
| 2328 |
} |
| 2329 |
break; |
| 2330 |
} |
| 2331 |
} |
| 2332 |
return null; |
| 2333 |
} |
| 2334 |
|
| 2335 |
String stripMnemonic (String string) { |
| 2336 |
int index = 0; |
| 2337 |
int length = string.length (); |
| 2338 |
do { |
| 2339 |
while ((index < length) && (string.charAt (index) != '&')) index++; |
| 2340 |
if (++index >= length) return string; |
| 2341 |
if (string.charAt (index) != '&') { |
| 2342 |
return string.substring(0, index-1) + string.substring(index, length); |
| 2343 |
} |
| 2344 |
index++; |
| 2345 |
} while (index < length); |
| 2346 |
return string; |
| 2347 |
} |
| 2348 |
|
| 2349 |
/* |
| 2350 |
* Return the lowercase of the first non-'&' character following |
| 2351 |
* an '&' character in the given string. If there are no '&' |
| 2352 |
* characters in the given string, return '\0'. |
| 2353 |
*/ |
| 2354 |
char _findMnemonic (String string) { |
| 2355 |
if (string == null) return '\0'; |
| 2356 |
int index = 0; |
| 2357 |
int length = string.length (); |
| 2358 |
do { |
| 2359 |
while (index < length && string.charAt (index) != '&') index++; |
| 2360 |
if (++index >= length) return '\0'; |
| 2361 |
if (string.charAt (index) != '&') return Character.toLowerCase (string.charAt (index)); |
| 2362 |
index++; |
| 2363 |
} while (index < length); |
| 2364 |
return '\0'; |
| 2365 |
} |
| 2366 |
|
| 2295 |
/* IAccessible::get_accParent([out] ppdispParent) |
2367 |
/* IAccessible::get_accParent([out] ppdispParent) |
| 2296 |
* Ownership of ppdispParent transfers from callee to caller so reference count on ppdispParent |
2368 |
* Ownership of ppdispParent transfers from callee to caller so reference count on ppdispParent |
| 2297 |
* must be incremented before returning. The caller is responsible for releasing ppdispParent. |
2369 |
* must be incremented before returning. The caller is responsible for releasing ppdispParent. |