< prev index next >

src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m

Print this page




1190     JNIEnv* env = [ThreadUtilities getJNIEnv];
1191 
1192     // Need to handle popupmenus differently.
1193     //
1194     // At least for now don't handle combo box menus.
1195     // This may change when later fixing issues which currently
1196     // exist for combo boxes, but for now the following is only
1197     // for JPopupMenus, not for combobox menus.
1198     id parent = [self parent];
1199     if ( [[self javaRole] isEqualToString:@"popupmenu"] &&
1200          ![[parent javaRole] isEqualToString:@"combobox"] ) {
1201         NSArray *children =
1202             [JavaComponentAccessibility childrenOfParent:self
1203                                         withEnv:env
1204                                         withChildrenCode:JAVA_AX_ALL_CHILDREN
1205                                         allowIgnored:YES];
1206         if ([children count] > 0) {
1207             // handle case of AXMenuItem
1208             // need to ask menu what is selected
1209             NSArray *selectedChildrenOfMenu =
1210                 [self accessibilitySelectedChildrenAttribute];
1211             JavaComponentAccessibility *selectedMenuItem =
1212                 [selectedChildrenOfMenu objectAtIndex:0];
1213             if (selectedMenuItem != nil) {
1214                 jobject itemValue =
1215                         JNFCallStaticObjectMethod( env,
1216                                                    sjm_getAccessibleName,
1217                                                    selectedMenuItem->fAccessible,
1218                                                    selectedMenuItem->fComponent ); // AWT_THREADING Safe (AWTRunLoop)
1219                 if (itemValue == NULL) {
1220                     return nil;
1221                 }
1222                 NSString* itemString = JNFJavaToNSString(env, itemValue);
1223                 (*env)->DeleteLocalRef(env, itemValue);
1224                 return itemString;
1225             } else {
1226                 return nil;
1227             }
1228         }
1229     }
1230 
1231     // ask Java for the component's accessibleValue. In java, the "accessibleValue" just means a numerical value
1232     // a text value is taken care of in JavaTextAccessibility
1233 
1234     // cmcnote should coalesce these calls into one java call
1235     NSNumber *num = nil;
1236     jobject axValue = JNFCallStaticObjectMethod(env, sjm_getAccessibleValue, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
1237     if (axValue != NULL) {
1238         jobject str = JNFCallStaticObjectMethod(env, jm_getCurrentAccessibleValue, axValue, fComponent);
1239         if (str != NULL) {
1240             num = JNFJavaToNSNumber(env, str); // AWT_THREADING Safe (AWTRunLoop)
1241             (*env)->DeleteLocalRef(env, str);
1242         }
1243         (*env)->DeleteLocalRef(env, axValue);
1244     }
1245     if (num == nil) {
1246         num = [NSNumber numberWithInt:0];




1190     JNIEnv* env = [ThreadUtilities getJNIEnv];
1191 
1192     // Need to handle popupmenus differently.
1193     //
1194     // At least for now don't handle combo box menus.
1195     // This may change when later fixing issues which currently
1196     // exist for combo boxes, but for now the following is only
1197     // for JPopupMenus, not for combobox menus.
1198     id parent = [self parent];
1199     if ( [[self javaRole] isEqualToString:@"popupmenu"] &&
1200          ![[parent javaRole] isEqualToString:@"combobox"] ) {
1201         NSArray *children =
1202             [JavaComponentAccessibility childrenOfParent:self
1203                                         withEnv:env
1204                                         withChildrenCode:JAVA_AX_ALL_CHILDREN
1205                                         allowIgnored:YES];
1206         if ([children count] > 0) {
1207             // handle case of AXMenuItem
1208             // need to ask menu what is selected
1209             NSArray *selectedChildrenOfMenu =
1210                 [self accessibilitySelectedChildrenAttribute];
1211             JavaComponentAccessibility *selectedMenuItem =
1212                 [selectedChildrenOfMenu objectAtIndex:0];
1213             if (selectedMenuItem != nil) {
1214                 jobject itemValue =
1215                         JNFCallStaticObjectMethod( env,
1216                                                    sjm_getAccessibleName,
1217                                                    selectedMenuItem->fAccessible,
1218                                                    selectedMenuItem->fComponent ); // AWT_THREADING Safe (AWTRunLoop)
1219                 if (itemValue == NULL) {
1220                     return nil;
1221                 }
1222                 NSString* itemString = JNFJavaToNSString(env, itemValue);
1223                 (*env)->DeleteLocalRef(env, itemValue);
1224                 return itemString;
1225             } else {
1226                 return nil;
1227             }
1228         }
1229     }
1230 
1231     // ask Java for the component's accessibleValue. In java, the "accessibleValue" just means a numerical value
1232     // a text value is taken care of in JavaTextAccessibility
1233 
1234     // cmcnote should coalesce these calls into one java call
1235     NSNumber *num = nil;
1236     jobject axValue = JNFCallStaticObjectMethod(env, sjm_getAccessibleValue, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
1237     if (axValue != NULL) {
1238         jobject str = JNFCallStaticObjectMethod(env, jm_getCurrentAccessibleValue, axValue, fComponent);
1239         if (str != NULL) {
1240             num = JNFJavaToNSNumber(env, str); // AWT_THREADING Safe (AWTRunLoop)
1241             (*env)->DeleteLocalRef(env, str);
1242         }
1243         (*env)->DeleteLocalRef(env, axValue);
1244     }
1245     if (num == nil) {
1246         num = [NSNumber numberWithInt:0];


< prev index next >