Skip to content

Commit

Permalink
8309558: Create implementation of NSAccessibilityCheckBox protocol
Browse files Browse the repository at this point in the history
8309629: Create implementation of NSAccessibilityRadioButton protocol

Reviewed-by: kcr, arapte
  • Loading branch information
Alexander Zuev authored and kevinrushforth committed Aug 17, 2023
1 parent e5bb4e1 commit 7b797b9
Show file tree
Hide file tree
Showing 6 changed files with 185 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,18 @@ + (void) initializeRolesMap {
/*
* Here we should keep all the mapping between the accessibility roles and implementing classes
*/
rolesMap = [[NSMutableDictionary alloc] initWithCapacity:4];
rolesMap = [[NSMutableDictionary alloc] initWithCapacity:8];

[rolesMap setObject:@"JFXButtonAccessibility" forKey:@"BUTTON"];
[rolesMap setObject:@"JFXButtonAccessibility" forKey:@"DECREMENT_BUTTON"];
[rolesMap setObject:@"JFXButtonAccessibility" forKey:@"INCREMENT_BUTTON"];
[rolesMap setObject:@"JFXButtonAccessibility" forKey:@"SPLIT_MENU_BUTTON"];
[rolesMap setObject:@"JFXRadiobuttonAccessibility" forKey:@"RADIO_BUTTON"];
// Requires TAB_GROUP to be implemented first
// [rolesMap setObject:@"JFXRadiobuttonAccessibility" forKey:@"TAB_ITEM"];
[rolesMap setObject:@"JFXRadiobuttonAccessibility" forKey:@"PAGE_ITEM"];
[rolesMap setObject:@"JFXCheckboxAccessibility" forKey:@"CHECK_BOX"];
[rolesMap setObject:@"JFXCheckboxAccessibility" forKey:@"TOGGLE_BUTTON"];

}

Expand Down Expand Up @@ -162,6 +168,27 @@ - (void)clearParent
parent = nil;
}

- (BOOL)isAccessibilityFocused
{
jobject jresult = NULL;
GET_MAIN_JENV;
if (env == NULL) return NO;
jresult = (jobject)(*env)->CallLongMethod(env, self->jAccessible, jAccessibilityAttributeValue, (jlong)@"AXFocused");
GLASS_CHECK_EXCEPTION(env);

return [variantToID(env, jresult) boolValue];
}

- (void)setAccessibilityFocused:(BOOL)value
{
GET_MAIN_JENV;
if (env == NULL) return;
(*env)->CallVoidMethod(env, self->jAccessible, jAccessibilitySetValue,
(jlong)[NSNumber numberWithBool:value],
(jlong)@"AXFocused");
GLASS_CHECK_EXCEPTION(env);
}

@end

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,13 @@ - (id)accessibilityParent
return [super accessibilityParent];
}

- (id)accessibilityValue
{
if ([self accessibilityRole] == NSAccessibilityButtonRole) {
return NULL;
} else {
return [super accessibilityValue];
}
}

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2023, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

#import "AccessibleBase.h"
#import "JFXButtonAccessibility.h"
#import <AppKit/AppKit.h>

@interface JFXCheckboxAccessibility : JFXButtonAccessibility <NSAccessibilityCheckBox> {

};
- (NSAccessibilityRole)accessibilityRole;
- (id)accessibilityValue;
@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2023, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

#import "JFXCheckboxAccessibility.h"

@implementation JFXCheckboxAccessibility
- (NSAccessibilityRole)accessibilityRole
{
return NSAccessibilityCheckBoxRole;
}

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

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2023, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

#import "AccessibleBase.h"
#import "JFXButtonAccessibility.h"
#import <AppKit/AppKit.h>

@interface JFXRadiobuttonAccessibility : JFXButtonAccessibility <NSAccessibilityRadioButton> {

};
- (NSAccessibilityRole)accessibilityRole;
- (id)accessibilityValue;
@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2023, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

#import "JFXRadiobuttonAccessibility.h"

@implementation JFXRadiobuttonAccessibility
- (NSAccessibilityRole)accessibilityRole
{
return NSAccessibilityRadioButtonRole;
}

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

@end

1 comment on commit 7b797b9

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