Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ public void dispose() {
/** {@inheritDoc} */
@Override public Object queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters) {
switch (attribute) {
case ROW_AT_INDEX: {
final int rowIndex = (Integer)parameters[0];
return rowIndex < 0 ? null : flow.getPrivateCell(rowIndex);
}
case SELECTED_ITEMS: {
List<Node> selection = new ArrayList<>();
TableViewSelectionModel<T> sm = getSkinnable().getSelectionModel();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2026, 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 @@ -27,7 +27,9 @@

import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.function.Function;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
Expand Down Expand Up @@ -1300,6 +1302,31 @@ private MacVariant accessibilityAttributeValue(long attribute) {
return null;
}
Object result = getAttribute(jfxAttr);
if (attr == MacAttribute.NSAccessibilitySelectedRowsAttribute
&& role == AccessibleRole.TABLE_VIEW) {
@SuppressWarnings("unchecked")
ObservableList<Node> selectedCells = (ObservableList<Node>)result;
Set<Node> selectedRows = new LinkedHashSet<>();
if (selectedCells != null) {
for (Node cell : selectedCells) {
Accessible cellAccessible = getAccessible(cell);
if (cellAccessible == null) {
continue;
}

Integer rowIndex = (Integer)cellAccessible.getAttribute(ROW_INDEX);
if (rowIndex == null) {
continue;
}

Node row = (Node)getAttribute(ROW_AT_INDEX, rowIndex);
if (row != null) {
selectedRows.add(row);
}
}
}
result = FXCollections.observableArrayList(selectedRows);
}
if (result == null) {
switch (attr) {
case NSAccessibilityParentAttribute: break;
Expand Down Expand Up @@ -1696,12 +1723,15 @@ private void accessibilitySetValue(long value, long attribute) {
if (variant != null && variant.longArray != null && variant.longArray.length > 0) {
long[] ids = variant.longArray;
ObservableList<Node> items = FXCollections.observableArrayList();
AccessibleRole controlRole = (AccessibleRole)getAttribute(ROLE);
for (long id : ids) {
MacAccessible acc = GlassAccessibleToMacAccessible(id);
if (acc != null) {
Integer index = (Integer)acc.getAttribute(INDEX);
if (index != null) {
Node cell = (Node)getAttribute(ROW_AT_INDEX, index);
AccessibleAttribute itemAttribute = controlRole == AccessibleRole.LIST_VIEW
? ITEM_AT_INDEX : ROW_AT_INDEX;
Node cell = (Node)getAttribute(itemAttribute, index);
if (cell != null) {
items.add(cell);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,13 @@ id jRole;
- (id)requestNodeAttribute:(NSString *)attribute;
- (id)requestNodeAttribute:(NSString *)attribute forParameter:(id)parameter;
- (BOOL)isNodeAttributeSettable:(NSString *)attribute;
- (NSInteger)requestNodeArrayAttributeCount:(NSString *)attribute;
- (NSArray *)requestNodeArrayAttribute:(NSString *)attribute index:(NSUInteger)index maxCount:(NSUInteger)maxCount;
- (void)setNodeAttribute:(id)value forAttribute:(NSString *)attribute;
- (NSString *)accessibilityPlaceholderValue;
- (NSRect)accessibilityFrame;
- (id)accessibilityParent;
- (id)accessibilityFocusedUIElement;
- (BOOL)isAccessibilityElement;
- (BOOL)performAccessibleAction:(NSString*)actionId;
+ (void) initializeRolesMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#import "com_sun_glass_ui_mac_MacAccessible.h"
#import "com_sun_glass_ui_mac_MacVariant.h"
#import "common.h"
#include <stdlib.h>

static NSMutableDictionary * rolesMap;

Expand All @@ -50,6 +51,7 @@ + (void) initializeRolesMap {
[rolesMap setObject:@"JFXImageAccessibility" forKey:@"IMAGE"];
[rolesMap setObject:@"JFXImageAccessibility" forKey:@"IMAGE_VIEW"];
[rolesMap setObject:@"JFXButtonAccessibility" forKey:@"INCREMENT_BUTTON"];
[rolesMap setObject:@"JFXListAccessibility" forKey:@"LIST_VIEW"];
[rolesMap setObject:@"JFXMenuItemAccessibility" forKey:@"MENU"];
[rolesMap setObject:@"JFXMenuBarAccessibility" forKey:@"MENU_BAR"];
[rolesMap setObject:@"JFXMenuItemAccessibility" forKey:@"MENU_ITEM"];
Expand All @@ -63,6 +65,7 @@ + (void) initializeRolesMap {
[rolesMap setObject:@"JFXButtonAccessibility" forKey:@"SPLIT_MENU_BUTTON"];
[rolesMap setObject:@"JFXRadiobuttonAccessibility" forKey:@"TAB_ITEM"];
[rolesMap setObject:@"JFXTabGroupAccessibility" forKey:@"TAB_PANE"];
[rolesMap setObject:@"JFXTableAccessibility" forKey:@"TABLE_VIEW"];
[rolesMap setObject:@"JFXStaticTextAccessibility" forKey:@"TEXT"];
[rolesMap setObject:@"JFXNavigableTextAccessibility" forKey:@"TEXT_AREA"];
[rolesMap setObject:@"JFXNavigableTextAccessibility" forKey:@"TEXT_FIELD"];
Expand Down Expand Up @@ -151,6 +154,34 @@ - (id)requestNodeAttribute:(NSString *)attribute forParameter:(id)parameter
return variantToID(env, jresult);
}

- (NSInteger)requestNodeArrayAttributeCount:(NSString *)attribute
{
GET_MAIN_JENV;
if (env == NULL) {
return -1;
}
jint jresult = (*env)->CallIntMethod(env, [self getJAccessible],
jAccessibilityArrayAttributeCount,
(jlong)attribute);
GLASS_CHECK_EXCEPTION(env);
return jresult;
}

- (NSArray *)requestNodeArrayAttribute:(NSString *)attribute index:(NSUInteger)index maxCount:(NSUInteger)maxCount
{
GET_MAIN_JENV;
if (env == NULL) {
return nil;
}
jlongArray jresult = (jlongArray)(*env)->CallObjectMethod(env, [self getJAccessible],
jAccessibilityArrayAttributeValues,
(jlong)attribute,
(jint)index,
(jint)maxCount);
GLASS_CHECK_EXCEPTION(env);
return jArrayToNSArray(env, jresult, jLongToID);
}

/*
* Check whether an accessibility attribute on the JavaFX Node can be set.
*/
Expand Down Expand Up @@ -227,6 +258,16 @@ - (NSArray *)accessibilityChildren
return [self requestNodeAttribute:@"AXChildren"];
}

- (id)accessibilityFocusedUIElement
{
GET_MAIN_JENV;
if (env == NULL) return NULL;
id result = (id)(*env)->CallLongMethod(env, self->jAccessible,
jAccessibilityFocusedUIElement);
GLASS_CHECK_EXCEPTION(env);
return result;
}

- (id)accessibilityRoleDescription
{
return [self requestNodeAttribute:@"AXRoleDescription"];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2026, 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 <AppKit/NSAccessibility.h>

@interface JFXListAccessibility : AccessibleBase {
};

- (NSAccessibilityRole)accessibilityRole;
- (NSString *)accessibilityLabel;
- (BOOL)isAccessibilityEnabled;
- (NSArray *)accessibilityChildren;
- (id)accessibilityParent;
- (NSRect)accessibilityFrame;
- (NSInteger)accessibilityColumnCount;
- (NSInteger)accessibilityRowCount;
- (NSArray *)accessibilityRows;
- (NSArray *)accessibilitySelectedRows;
- (void)setAccessibilitySelectedRows:(NSArray *)selectedRows;
@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/*
* Copyright (c) 2026, 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 "JFXListAccessibility.h"

@implementation JFXListAccessibility
- (NSAccessibilityRole)accessibilityRole
{
// This can change to NSAccessibilityListRole in the future.
return NSAccessibilityTableRole;
}

- (NSString *)accessibilityLabel
{
return [super accessibilityLabel];
}

- (BOOL)isAccessibilityEnabled
{
id retVal = [self requestNodeAttribute:@"AXEnabled"];
if (retVal == NULL) {
return YES;
}
return [retVal boolValue];
}

- (NSArray *)accessibilityChildren
{
return [super accessibilityChildren];
}

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

- (NSRect)accessibilityFrame
{
return [super accessibilityFrame];
}

- (NSInteger)accessibilityColumnCount
{
id retVal = [self requestNodeAttribute:@"AXColumnCount"];
return retVal != NULL ? [retVal integerValue] : 1;
}

- (NSInteger)accessibilityRowCount
{
id retVal = [self requestNodeAttribute:@"AXRowCount"];
if (retVal == NULL) {
return [self accessibilityArrayCountForAttribute:@"AXRows"];
}
return [retVal integerValue];
}

- (NSArray *)accessibilityRows
{
return [self accessibilityArrayForAttribute:@"AXRows"];
}

- (NSArray *)accessibilitySelectedRows
{
return [self requestNodeAttribute:@"AXSelectedRows"];
}

- (void)setAccessibilitySelectedRows:(NSArray *)selectedRows
{
[self setNodeAttribute:selectedRows forAttribute:@"AXSelectedRows"];
}

- (NSArray *)accessibilityArrayForAttribute:(NSString *)attribute
{
NSInteger count = [self accessibilityArrayCountForAttribute:attribute];
if (count < 0) {
return nil;
}
if (count == 0) {
return @[];
}
NSArray *result = [self requestNodeArrayAttribute:attribute index:0 maxCount:(NSUInteger)count];
if (result == nil) {
result = [super accessibilityArrayAttributeValues:attribute index:0 maxCount:(NSUInteger)count];
}
return result;
}

- (NSInteger)accessibilityArrayCountForAttribute:(NSString *)attribute
{
NSInteger count = [self requestNodeArrayAttributeCount:attribute];
if (count < 0) {
count = [super accessibilityArrayAttributeCount:attribute];
}
return count;
}

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2026, 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 <AppKit/NSAccessibility.h>

@interface JFXTableAccessibility : AccessibleBase <NSAccessibilityTable> {
};

- (NSAccessibilityRole)accessibilityRole;
- (NSString *)accessibilityLabel;
- (BOOL)isAccessibilityEnabled;
- (NSArray *)accessibilityChildren;
- (id)accessibilityParent;
- (NSRect)accessibilityFrame;
- (id)accessibilityHeader;
- (NSInteger)accessibilityColumnCount;
- (NSInteger)accessibilityRowCount;
- (NSArray *)accessibilityColumns;
- (NSArray *)accessibilityRows;
- (NSArray *)accessibilitySelectedRows;
- (void)setAccessibilitySelectedRows:(NSArray *)selectedRows;
- (NSArray *)accessibilitySelectedCells;
- (void)setAccessibilitySelectedCells:(NSArray *)selectedCells;
- (id)accessibilityCellForColumn:(NSInteger)column row:(NSInteger)row;
@end
Loading