Skip to content

Commit

Permalink
8283383: [macos] a11y : Screen magnifier shows extra characters (0) a…
Browse files Browse the repository at this point in the history
…t the end JButton accessibility name

Backport-of: b021d37cec557059e288d5937a73577233b0b172
  • Loading branch information
Jonathan Dowland committed Sep 7, 2022
1 parent 13ed26b commit cd7da2d
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 7 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -54,4 +54,15 @@ - (id)accessibilityParent
return [super accessibilityParent];
}

- (id _Nullable)accessibilityValue
{
if ([self accessibilityRole] == NSAccessibilityButtonRole) {
// Only do it for buttons, radio buttons and checkbox buttons
// have a meaningful value to return
return NULL;
} else {
return [super accessibilityValue];
}
}

@end
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -126,7 +126,7 @@ + (void) initializeRolesMap {
/*
* Here we should keep all the mapping between the accessibility roles and implementing classes
*/
rolesMap = [[NSMutableDictionary alloc] initWithCapacity:50];
rolesMap = [[NSMutableDictionary alloc] initWithCapacity:51];

[rolesMap setObject:@"ButtonAccessibility" forKey:@"pushbutton"];
[rolesMap setObject:@"ImageAccessibility" forKey:@"icon"];
Expand Down Expand Up @@ -159,6 +159,7 @@ + (void) initializeRolesMap {
[rolesMap setObject:@"MenuBarAccessibility" forKey:@"menubar"];
[rolesMap setObject:@"MenuAccessibility" forKey:@"menu"];
[rolesMap setObject:@"MenuAccessibility" forKey:@"popupmenu"];
[rolesMap setObject:@"MenuItemAccessibility" forKey:@"menuitem"];
[rolesMap setObject:@"ProgressIndicatorAccessibility" forKey:@"progressbar"];

/*
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -49,4 +49,9 @@ - (id)accessibilityParent
return [super accessibilityParent];
}

- (id _Nullable)accessibilityValue
{
return NULL;
}

@end
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -42,4 +42,9 @@ - (BOOL)isAccessibilityElement
return YES;
}

- (id _Nullable)accessibilityValue
{
return NULL;
}

@end
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -56,7 +56,7 @@ - (NSString * _Nullable)accessibilityLabel

- (id _Nullable)accessibilityValue
{
return [super accessibilityValue];
return NULL;
}

@end

1 comment on commit cd7da2d

@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.