Skip to content

Commit

Permalink
7124301: [macosx] When in a tab group if you arrow between tabs there…
Browse files Browse the repository at this point in the history
… are no VoiceOver announcements.

Reviewed-by: goetz
Backport-of: 2146e52
  • Loading branch information
TheRealMDoerr committed May 20, 2022
1 parent 3072af4 commit 8533ba4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessible.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.swing.JProgressBar;
import javax.swing.JTabbedPane;
import javax.swing.JSlider;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
Expand All @@ -42,6 +43,8 @@
import static javax.accessibility.AccessibleContext.ACCESSIBLE_STATE_PROPERTY;
import static javax.accessibility.AccessibleContext.ACCESSIBLE_TABLE_MODEL_CHANGED;
import static javax.accessibility.AccessibleContext.ACCESSIBLE_TEXT_PROPERTY;
import static javax.accessibility.AccessibleContext.ACCESSIBLE_NAME_PROPERTY;

import javax.accessibility.AccessibleRole;
import javax.accessibility.AccessibleState;
import sun.awt.AWTAccessor;
Expand All @@ -67,6 +70,7 @@ public static CAccessible getCAccessible(final Accessible a) {
private static native void valueChanged(long ptr);
private static native void selectedTextChanged(long ptr);
private static native void selectionChanged(long ptr);
private static native void titleChanged(long ptr);
private static native void menuOpened(long ptr);
private static native void menuClosed(long ptr);
private static native void menuItemSelected(long ptr);
Expand Down Expand Up @@ -122,9 +126,9 @@ public void propertyChange(PropertyChangeEvent e) {
Object oldValue = e.getOldValue();
if (name.compareTo(ACCESSIBLE_CARET_PROPERTY) == 0) {
selectedTextChanged(ptr);
} else if (name.compareTo(ACCESSIBLE_TEXT_PROPERTY) == 0 ) {
} else if (name.compareTo(ACCESSIBLE_TEXT_PROPERTY) == 0) {
valueChanged(ptr);
} else if (name.compareTo(ACCESSIBLE_SELECTION_PROPERTY) == 0 ) {
} else if (name.compareTo(ACCESSIBLE_SELECTION_PROPERTY) == 0) {
selectionChanged(ptr);
} else if (name.compareTo(ACCESSIBLE_TABLE_MODEL_CHANGED) == 0) {
valueChanged(ptr);
Expand Down Expand Up @@ -160,6 +164,11 @@ public void propertyChange(PropertyChangeEvent e) {
}
}
}
} else if (name.compareTo(ACCESSIBLE_NAME_PROPERTY) == 0) {
//for now trigger only for JTabbedPane.
if (e.getSource() instanceof JTabbedPane) {
titleChanged(ptr);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
- (void)postValueChanged;
- (void)postSelectedTextChanged;
- (void)postSelectionChanged;
- (void)postTitleChanged;
- (BOOL)isEqual:(id)anObject;
- (BOOL)isAccessibleWithEnv:(JNIEnv *)env forAccessible:(jobject)accessible;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@ - (void)postSelectionChanged
NSAccessibilityPostNotification(self, NSAccessibilitySelectedChildrenChangedNotification);
}

-(void)postTitleChanged
{
AWT_ASSERT_APPKIT_THREAD;
NSAccessibilityPostNotification(self, NSAccessibilityTitleChangedNotification);
}

- (void)postMenuOpened
{
AWT_ASSERT_APPKIT_THREAD;
Expand Down Expand Up @@ -544,7 +550,8 @@ - (NSArray *)initializeAttributeNamesWithEnv:(JNIEnv *)env
if (attributeStatesArray[6]) {
[attributeNames addObject:NSAccessibilityChildrenAttribute];
if ([javaRole isEqualToString:@"list"]
|| [javaRole isEqualToString:@"table"]) {
|| [javaRole isEqualToString:@"table"]
|| [javaRole isEqualToString:@"pagetablist"]) {
[attributeNames addObject:NSAccessibilitySelectedChildrenAttribute];
[attributeNames addObject:NSAccessibilityVisibleChildrenAttribute];
}
Expand Down Expand Up @@ -1531,6 +1538,19 @@ - (id)accessibilityFocusedUIElement
JNI_COCOA_EXIT(env);
}

/*
* Class: sun_lwawt_macosx_CAccessible
* Method: titleChanged
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_titleChanged
(JNIEnv *env, jclass jklass, jlong element)
{
JNI_COCOA_ENTER(env);
[ThreadUtilities performOnMainThread:@selector(postTitleChanged) on:(JavaComponentAccessibility*)jlong_to_ptr(element) withObject:nil waitUntilDone:NO];
JNI_COCOA_EXIT(env);
}

/*
* Class: sun_lwawt_macosx_CAccessible
* Method: valueChanged
Expand Down

1 comment on commit 8533ba4

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.