diff --git a/modules/javafx.graphics/src/main/native-glass/mac/a11y/AccessibleBase.h b/modules/javafx.graphics/src/main/native-glass/mac/a11y/AccessibleBase.h index 772a0694d0d..83e8fba08cc 100644 --- a/modules/javafx.graphics/src/main/native-glass/mac/a11y/AccessibleBase.h +++ b/modules/javafx.graphics/src/main/native-glass/mac/a11y/AccessibleBase.h @@ -26,6 +26,9 @@ #import #import +#define INCREMENT @"AXIncrement" +#define DECREMENT @"AXDecrement" + @interface AccessibleBase : NSAccessibilityElement { @private jobject jAccessible; diff --git a/modules/javafx.graphics/src/main/native-glass/mac/a11y/AccessibleBase.m b/modules/javafx.graphics/src/main/native-glass/mac/a11y/AccessibleBase.m index 5d559c453c5..36b709f9f3f 100644 --- a/modules/javafx.graphics/src/main/native-glass/mac/a11y/AccessibleBase.m +++ b/modules/javafx.graphics/src/main/native-glass/mac/a11y/AccessibleBase.m @@ -40,7 +40,7 @@ + (void) initializeRolesMap { * All JavaFX roles and corresponding available properties are defined in * enum javafx.scene.AccessibleRole */ - rolesMap = [[NSMutableDictionary alloc] initWithCapacity:9]; + rolesMap = [[NSMutableDictionary alloc] initWithCapacity:11]; [rolesMap setObject:@"JFXButtonAccessibility" forKey:@"BUTTON"]; [rolesMap setObject:@"JFXButtonAccessibility" forKey:@"DECREMENT_BUTTON"]; @@ -53,6 +53,8 @@ + (void) initializeRolesMap { [rolesMap setObject:@"JFXCheckboxAccessibility" forKey:@"CHECK_BOX"]; [rolesMap setObject:@"JFXCheckboxAccessibility" forKey:@"TOGGLE_BUTTON"]; [rolesMap setObject:@"JFXStaticTextAccessibility" forKey:@"TEXT"]; + [rolesMap setObject:@"JFXStepperAccessibility" forKey:@"SPINNER"]; + [rolesMap setObject:@"JFXSliderAccessibility" forKey:@"SLIDER"]; } @@ -105,16 +107,35 @@ - (id)accessibilityValue return variantToID(env, jresult); } -- (NSString *)accessibilityLabel +- (id)accessibilityMinValue +{ + jobject jresult = NULL; + GET_MAIN_JENV; + if (env == NULL) return NULL; + jresult = (jobject)(*env)->CallLongMethod(env, self->jAccessible, + jAccessibilityAttributeValue, (jlong)@"AXMinValue"); + GLASS_CHECK_EXCEPTION(env); + return variantToID(env, jresult); +} + +- (id)accessibilityMaxValue { jobject jresult = NULL; GET_MAIN_JENV; if (env == NULL) return NULL; - jresult = (jobject)(*env)->CallLongMethod(env, self->jAccessible, jAccessibilityAttributeValue, (jlong)@"AXTitle"); + jresult = (jobject)(*env)->CallLongMethod(env, self->jAccessible, + jAccessibilityAttributeValue, (jlong)@"AXMaxValue"); GLASS_CHECK_EXCEPTION(env); return variantToID(env, jresult); } +- (NSString *)accessibilityLabel +{ + // Use the same value that is set for accessibilityTitle - some component + // do not have titles and request it as a label + return [self accessibilityTitle]; +} + - (id)accessibilityParent { if (parent == nil) { @@ -129,6 +150,30 @@ - (id)accessibilityParent return parent; } +- (id)accessibilityTitle +{ + jobject jresult = NULL; + GET_MAIN_JENV; + if (env == NULL) return NULL; + jresult = (jobject)(*env)->CallLongMethod(env, self->jAccessible, + jAccessibilityAttributeValue, (jlong)@"AXTitle"); + GLASS_CHECK_EXCEPTION(env); + return variantToID(env, jresult); +} + +- (id)accessibilityTitleUIElement +{ + jobject jresult = NULL; + GET_MAIN_JENV; + if (env == NULL) return NULL; + jresult = (jobject)(*env)->CallLongMethod(env, self->jAccessible, jAccessibilityAttributeValue, + (jlong)@"AXTitleUIElement"); + GLASS_CHECK_EXCEPTION(env); + return variantToID(env, jresult); +} + + + // Actions support - (BOOL)performAccessibleAction:(NSString *)action { diff --git a/modules/javafx.graphics/src/main/native-glass/mac/a11y/JFXSliderAccessibility.h b/modules/javafx.graphics/src/main/native-glass/mac/a11y/JFXSliderAccessibility.h new file mode 100644 index 00000000000..53d68171e85 --- /dev/null +++ b/modules/javafx.graphics/src/main/native-glass/mac/a11y/JFXSliderAccessibility.h @@ -0,0 +1,37 @@ +/* + * 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 + +@interface JFXSliderAccessibility : AccessibleBase { + +}; +- (NSAccessibilityRole)accessibilityRole; +- (NSString *)accessibilityLabel; +- (id)accessibilityValue; +- (BOOL)accessibilityPerformDecrement; +- (BOOL)accessibilityPerformIncrement; +@end diff --git a/modules/javafx.graphics/src/main/native-glass/mac/a11y/JFXSliderAccessibility.m b/modules/javafx.graphics/src/main/native-glass/mac/a11y/JFXSliderAccessibility.m new file mode 100644 index 00000000000..68af642bd5f --- /dev/null +++ b/modules/javafx.graphics/src/main/native-glass/mac/a11y/JFXSliderAccessibility.m @@ -0,0 +1,73 @@ +/* + * 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 "JFXSliderAccessibility.h" + +/* + * Implementation of the accessibility peer for the slider role + */ + +@implementation JFXSliderAccessibility +- (NSAccessibilityRole)accessibilityRole +{ + return NSAccessibilitySliderRole; +} + +- (NSString *)accessibilityLabel +{ + return [super accessibilityLabel]; +} + +- (id)accessibilityValue +{ + return [super accessibilityValue]; +} + +- (id)accessibilityTitle +{ + return [super accessibilityTitle]; +} + +- (BOOL)accessibilityPerformIncrement +{ + return [self performAccessibleAction:INCREMENT]; +} + +- (BOOL)accessibilityPerformDecrement +{ + return [self performAccessibleAction:DECREMENT]; +} + +- (NSRect)accessibilityFrame +{ + return [super accessibilityFrame]; +} + +- (id)accessibilityParent +{ + return [super accessibilityParent]; +} + +@end diff --git a/modules/javafx.graphics/src/main/native-glass/mac/a11y/JFXStepperAccessibility.h b/modules/javafx.graphics/src/main/native-glass/mac/a11y/JFXStepperAccessibility.h new file mode 100644 index 00000000000..3da121a05de --- /dev/null +++ b/modules/javafx.graphics/src/main/native-glass/mac/a11y/JFXStepperAccessibility.h @@ -0,0 +1,37 @@ +/* + * 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 + +@interface JFXStepperAccessibility : AccessibleBase { + +}; +- (NSAccessibilityRole)accessibilityRole; +- (NSString *)accessibilityLabel; +- (id)accessibilityValue; +- (BOOL)accessibilityPerformDecrement; +- (BOOL)accessibilityPerformIncrement; +@end diff --git a/modules/javafx.graphics/src/main/native-glass/mac/a11y/JFXStepperAccessibility.m b/modules/javafx.graphics/src/main/native-glass/mac/a11y/JFXStepperAccessibility.m new file mode 100644 index 00000000000..fc1a79f5487 --- /dev/null +++ b/modules/javafx.graphics/src/main/native-glass/mac/a11y/JFXStepperAccessibility.m @@ -0,0 +1,78 @@ +/* + * 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 "JFXStepperAccessibility.h" + +/* + * Implementation of the accessibility peer for the stepper role + */ + +@implementation JFXStepperAccessibility +- (NSAccessibilityRole)accessibilityRole +{ + return NSAccessibilityIncrementorRole; +} + +- (NSString *)accessibilityLabel +{ + return [super accessibilityLabel]; +} + +- (id)accessibilityValue +{ + return [super accessibilityValue]; +} + +- (id)accessibilityMinValue +{ + return [super accessibilityMinValue]; +} + +- (id)accessibilityMaxValue +{ + return [super accessibilityMaxValue]; +} + +- (BOOL)accessibilityPerformIncrement +{ + return [self performAccessibleAction:INCREMENT]; +} + +- (BOOL)accessibilityPerformDecrement +{ + return [self performAccessibleAction:DECREMENT]; +} + +- (NSRect)accessibilityFrame +{ + return [super accessibilityFrame]; +} + +- (id)accessibilityParent +{ + return [super accessibilityParent]; +} + +@end