< prev index next >

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

Print this page

        

*** 64,74 **** static JNF_CLASS_CACHE(sjc_CAccessible, "sun/lwawt/macosx/CAccessible"); static JNF_MEMBER_CACHE(jf_ptr, sjc_CAccessible, "ptr", "J"); static JNF_STATIC_MEMBER_CACHE(sjm_getCAccessible, sjc_CAccessible, "getCAccessible", "(Ljavax/accessibility/Accessible;)Lsun/lwawt/macosx/CAccessible;"); - static jobject sAccessibilityClass = NULL; // sAttributeNamesForRoleCache holds the names of the attributes to which each java // AccessibleRole responds (see AccessibleRole.java). // This cache is queried before attempting to access a given attribute for a particular role. --- 64,73 ----
*** 211,220 **** --- 210,237 ---- { AWT_ASSERT_APPKIT_THREAD; NSAccessibilityPostNotification(self, NSAccessibilitySelectedChildrenChangedNotification); } + - (void)postMenuOpened + { + AWT_ASSERT_APPKIT_THREAD; + NSAccessibilityPostNotification(self, (NSString *)kAXMenuOpenedNotification); + } + + - (void)postMenuClosed + { + AWT_ASSERT_APPKIT_THREAD; + NSAccessibilityPostNotification(self, (NSString *)kAXMenuClosedNotification); + } + + - (void)postMenuItemSelected + { + AWT_ASSERT_APPKIT_THREAD; + NSAccessibilityPostNotification(self, (NSString *)kAXMenuItemSelectedNotification); + } + - (BOOL)isEqual:(id)anObject { if (![anObject isKindOfClass:[self class]]) return NO; JavaComponentAccessibility *accessibility = (JavaComponentAccessibility *)anObject;
*** 276,287 **** } + (jobject) getCAccessible:(jobject)jaccessible withEnv:(JNIEnv *)env { if (JNFIsInstanceOf(env, jaccessible, &sjc_CAccessible)) { return jaccessible; ! } ! else if (JNFIsInstanceOf(env, jaccessible, &sjc_Accessible)) { return JNFCallStaticObjectMethod(env, sjm_getCAccessible, jaccessible); } return NULL; } --- 293,303 ---- } + (jobject) getCAccessible:(jobject)jaccessible withEnv:(JNIEnv *)env { if (JNFIsInstanceOf(env, jaccessible, &sjc_CAccessible)) { return jaccessible; ! } else if (JNFIsInstanceOf(env, jaccessible, &sjc_Accessible)) { return JNFCallStaticObjectMethod(env, sjm_getCAccessible, jaccessible); } return NULL; }
*** 362,371 **** --- 378,395 ---- } // must init freshly -alloc'd object [newChild initWithParent:parent withEnv:env withAccessible:jCAX withIndex:index withView:view withJavaRole:javaRole]; // must init new instance + // If creating a JPopupMenu (not a combobox popup list) need to fire menuOpened. + // This is the only way to know if the menu is opening; visible state change + // can't be caught because the listeners are not set up in time. + if ( [javaRole isEqualToString:@"popupmenu"] && + ![[parent javaRole] isEqualToString:@"combobox"] ) { + [newChild postMenuOpened]; + } + // must hard retain pointer poked into Java object [newChild retain]; JNFSetLongField(env, jCAX, jf_ptr, ptr_to_jlong(newChild)); (*env)->DeleteLocalRef(env, jCAX);
*** 628,637 **** --- 652,670 ---- [moreNames addObject:NSAccessibilitySelectedAttribute]; [moreNames addObject:NSAccessibilityIndexAttribute]; return moreNames; } } + // popupmenu's return values not selected children + if ( [javaRole isEqualToString:@"popupmenu"] && + ![[[self parent] javaRole] isEqualToString:@"combobox"] ) { + NSMutableArray *moreNames = + [[NSMutableArray alloc] initWithCapacity: [names count] + 1]; + [moreNames addObjectsFromArray: names]; + [moreNames addObject:NSAccessibilityValueAttribute]; + return moreNames; + } return names; } // end @synchronized #ifdef JAVA_AX_DEBUG
*** 701,710 **** --- 734,744 ---- value = children; } return value; } + - (BOOL)accessibilityIsChildrenAttributeSettable { return NO; }
*** 933,950 **** --- 967,992 ---- - (NSString *)accessibilityRoleAttribute { if (fNSRole == nil) { NSString *javaRole = [self javaRole]; fNSRole = [sRoles objectForKey:javaRole]; + // The sRoles NSMutableDictionary maps popupmenu to Mac's popup button. + // JComboBox behavior currently relies on this. However this is not the + // proper mapping for a JPopupMenu so fix that. + if ( [javaRole isEqualToString:@"popupmenu"] && + ![[[self parent] javaRole] isEqualToString:@"combobox"] ) { + fNSRole = NSAccessibilityMenuRole; + } if (fNSRole == nil) { // this component has assigned itself a custom AccessibleRole not in the sRoles array fNSRole = javaRole; } [fNSRole retain]; } return fNSRole; } + - (BOOL)accessibilityIsRoleAttributeSettable { return NO; }
*** 1040,1051 **** // Element subrole type, such as NSAccessibilityTableRowSubrole (NSString). See the subrole attribute table at // http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/ObjC_classic/Protocols/NSAccessibility.html - (NSString *)accessibilitySubroleAttribute { NSString *value = nil; ! if ([[self javaRole] isEqualToString:@"passwordtext"]) ! { value = NSAccessibilitySecureTextFieldSubrole; } /* // other subroles. TableRow and OutlineRow may be relevant to us NSAccessibilityCloseButtonSubrole // no, heavyweight window takes care of this --- 1082,1092 ---- // Element subrole type, such as NSAccessibilityTableRowSubrole (NSString). See the subrole attribute table at // http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/ObjC_classic/Protocols/NSAccessibility.html - (NSString *)accessibilitySubroleAttribute { NSString *value = nil; ! if ([[self javaRole] isEqualToString:@"passwordtext"]) { value = NSAccessibilitySecureTextFieldSubrole; } /* // other subroles. TableRow and OutlineRow may be relevant to us NSAccessibilityCloseButtonSubrole // no, heavyweight window takes care of this
*** 1117,1126 **** --- 1158,1206 ---- { static JNF_STATIC_MEMBER_CACHE(jm_getCurrentAccessibleValue, sjc_CAccessibility, "getCurrentAccessibleValue", "(Ljavax/accessibility/AccessibleValue;Ljava/awt/Component;)Ljava/lang/Number;"); JNIEnv* env = [ThreadUtilities getJNIEnv]; + // Need to handle popupmenus differently. + // + // At least for now don't handle combo box menus. + // This may change when later fixing issues which currently + // exist for combo boxes, but for now the following is only + // for JPopupMenus, not for combobox menus. + id parent = [self parent]; + if ( [[self javaRole] isEqualToString:@"popupmenu"] && + ![[parent javaRole] isEqualToString:@"combobox"] ) { + NSArray *children = + [JavaComponentAccessibility childrenOfParent:self + withEnv:env + withChildrenCode:JAVA_AX_ALL_CHILDREN + allowIgnored:YES]; + if ([children count] > 0) { + // handle case of AXMenuItem + // need to ask menu what is selected + NSArray *selectedChildrenOfMenu = + [self accessibilitySelectedChildrenAttribute]; + JavaComponentAccessibility *selectedMenuItem = + [selectedChildrenOfMenu objectAtIndex:0]; + if (selectedMenuItem != nil) { + jobject itemValue = + JNFCallStaticObjectMethod( env, + sjm_getAccessibleName, + selectedMenuItem->fAccessible, + selectedMenuItem->fComponent ); // AWT_THREADING Safe (AWTRunLoop) + if (itemValue == NULL) { + return nil; + } + NSString* itemString = JNFJavaToNSString(env, itemValue); + (*env)->DeleteLocalRef(env, itemValue); + return itemString; + } else { + return nil; + } + } + } + // ask Java for the component's accessibleValue. In java, the "accessibleValue" just means a numerical value // a text value is taken care of in JavaTextAccessibility // cmcnote should coalesce these calls into one java call NSNumber *num = nil;
*** 1339,1348 **** --- 1419,1476 ---- JNF_COCOA_EXIT(env); } /* * Class: sun_lwawt_macosx_CAccessible + * Method: menuOpened + * Signature: (I)V + */ + JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_menuOpened + (JNIEnv *env, jclass jklass, jlong element) + { + JNF_COCOA_ENTER(env); + [ThreadUtilities performOnMainThread:@selector(postMenuOpened) + on:(JavaComponentAccessibility *)jlong_to_ptr(element) + withObject:nil + waitUntilDone:NO]; + JNF_COCOA_EXIT(env); + } + + /* + * Class: sun_lwawt_macosx_CAccessible + * Method: menuClosed + * Signature: (I)V + */ + JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_menuClosed + (JNIEnv *env, jclass jklass, jlong element) + { + JNF_COCOA_ENTER(env); + [ThreadUtilities performOnMainThread:@selector(postMenuClosed) + on:(JavaComponentAccessibility *)jlong_to_ptr(element) + withObject:nil + waitUntilDone:NO]; + JNF_COCOA_EXIT(env); + } + + /* + * Class: sun_lwawt_macosx_CAccessible + * Method: menuItemSelected + * Signature: (I)V + */ + JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_menuItemSelected + (JNIEnv *env, jclass jklass, jlong element) + { + JNF_COCOA_ENTER(env); + [ThreadUtilities performOnMainThread:@selector(postMenuItemSelected) + on:(JavaComponentAccessibility *)jlong_to_ptr(element) + withObject:nil + waitUntilDone:NO]; + JNF_COCOA_EXIT(env); + } + + /* + * Class: sun_lwawt_macosx_CAccessible * Method: unregisterFromCocoaAXSystem * Signature: (I)V */ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_unregisterFromCocoaAXSystem (JNIEnv *env, jclass jklass, jlong element)
< prev index next >