|
1 | 1 | /* |
2 | | - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. |
3 | | - * Copyright (c) 2021, JetBrains s.r.o.. All rights reserved. |
| 2 | + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. |
| 3 | + * Copyright (c) 2022, JetBrains s.r.o.. All rights reserved. |
4 | 4 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5 | 5 | * |
6 | 6 | * This code is free software; you can redistribute it and/or modify it |
|
37 | 37 | GET_STATIC_METHOD_RETURN(sjm_getAccessibleName, sjc_CAccessibility, "getAccessibleName", \ |
38 | 38 | "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;", ret); |
39 | 39 |
|
40 | | -static jmethodID sjm_getAccessibleSelection = NULL; |
41 | | -#define GET_ACCESSIBLESELECTION_METHOD_RETURN(ret) \ |
42 | | - GET_CACCESSIBILITY_CLASS_RETURN(ret); \ |
43 | | - GET_STATIC_METHOD_RETURN(sjm_getAccessibleSelection, sjc_CAccessibility, "getAccessibleSelection", \ |
44 | | - "(Ljavax/accessibility/AccessibleContext;Ljava/awt/Component;)Ljavax/accessibility/AccessibleSelection;", ret); |
45 | | - |
46 | 40 | @implementation ComboBoxAccessibility |
47 | 41 |
|
48 | | -// NSAccessibilityElement protocol methods |
49 | | - |
50 | | -- (id)accessibilityValue { |
| 42 | +- (CommonComponentAccessibility *)accessibleSelection |
| 43 | +{ |
51 | 44 | JNIEnv *env = [ThreadUtilities getJNIEnv]; |
52 | | - jobject axContext = [self axContextWithEnv:env]; |
53 | | - if (axContext == NULL) return nil; |
54 | | - GET_ACCESSIBLESELECTION_METHOD_RETURN(nil); |
55 | | - jobject axSelection = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, sjm_getAccessibleSelection, axContext, self->fComponent); |
56 | | - CHECK_EXCEPTION(); |
57 | | - if (axSelection == NULL) { |
58 | | - return nil; |
59 | | - } |
60 | | - jclass axSelectionClass = (*env)->GetObjectClass(env, axSelection); |
61 | | - DECLARE_METHOD_RETURN(jm_getAccessibleSelection, axSelectionClass, "getAccessibleSelection", "(I)Ljavax/accessibility/Accessible;", nil); |
62 | | - jobject axSelectedChild = (*env)->CallObjectMethod(env, axSelection, jm_getAccessibleSelection, 0); |
| 45 | + GET_CACCESSIBILITY_CLASS_RETURN(nil); |
| 46 | + DECLARE_STATIC_METHOD_RETURN(sjm_getAccessibleComboboxValue, sjc_CAccessibility, "getAccessibleComboboxValue", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/Accessible;", nil); |
| 47 | + jobject axSelectedChild = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, sjm_getAccessibleComboboxValue, fAccessible, fComponent); |
63 | 48 | CHECK_EXCEPTION(); |
64 | | - (*env)->DeleteLocalRef(env, axSelection); |
65 | | - (*env)->DeleteLocalRef(env, axContext); |
66 | 49 | if (axSelectedChild == NULL) { |
67 | 50 | return nil; |
68 | 51 | } |
69 | | - GET_ACCESSIBLENAME_METHOD_RETURN(nil); |
70 | | - jobject childName = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, sjm_getAccessibleName, axSelectedChild, fComponent); |
71 | | - CHECK_EXCEPTION(); |
72 | | - if (childName == NULL) { |
73 | | - (*env)->DeleteLocalRef(env, axSelectedChild); |
74 | | - return nil; |
75 | | - } |
76 | | - NSString *selectedText = JavaStringToNSString(env, childName); |
77 | | - (*env)->DeleteLocalRef(env, axSelectedChild); |
78 | | - (*env)->DeleteLocalRef(env, childName); |
79 | | - return selectedText; |
| 52 | + return [CommonComponentAccessibility createWithAccessible:axSelectedChild withEnv:env withView:fView]; |
| 53 | +} |
| 54 | + |
| 55 | +// NSAccessibilityElement protocol methods |
| 56 | + |
| 57 | +- (id)accessibilityValue |
| 58 | +{ |
| 59 | + return [[self accessibleSelection] accessibilityLabel]; |
80 | 60 | } |
81 | 61 |
|
82 | 62 | @end |
0 commit comments